alran 0.0.0-stage → 1.0.1
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/ALRAN_TOOLS_NOTICES.md +75 -0
- package/LICENSE +27 -0
- package/LICENSE-STATUS.md +21 -0
- package/NOTICE +6 -0
- package/README.md +284 -2
- package/THIRD_PARTY_NOTICES.md +113 -0
- package/alran-tools.js +3 -0
- package/assets/agents/_default/prompt-auto_classifier.md +185 -0
- package/assets/agents/_default/prompt-auto_classifier_extras.md +17 -0
- package/assets/agents/_default/prompt-base-all.md +133 -0
- package/assets/agents/_default/prompt-base-all.md.hbs +228 -0
- package/assets/agents/_default/prompt-base-windows.md +5 -0
- package/assets/agents/_default/prompt-base-windows.md.hbs +5 -0
- package/assets/agents/_default/prompt-base-worker.md +10 -0
- package/assets/agents/_default/prompt-base-worker.md.hbs +27 -0
- package/assets/agents/_default/prompt-compact.md +76 -0
- package/assets/agents/_default/prompt-compact_continue.md +9 -0
- package/assets/agents/_default/prompt-git.md +8 -0
- package/assets/agents/_default/prompt-goal.md +13 -0
- package/assets/agents/_default/prompt-session-branch.md +3 -0
- package/assets/agents/_default/prompt-session-branch.md.hbs +30 -0
- package/assets/agents/_default/prompt-session-root.md +3 -0
- package/assets/agents/_default/prompt-session-root.md.hbs +32 -0
- package/assets/agents/_default/prompt-title.md +11 -0
- package/assets/agents/_default/prompt-tool_agent.md +22 -0
- package/assets/agents/_migration/README.md +20 -0
- package/assets/agents/_migration/coder/PERSONA.md +11 -0
- package/assets/agents/_migration/coder/system-prompt.md.hbs +42 -0
- package/assets/agents/_migration/general/PERSONA.md +11 -0
- package/assets/agents/_migration/general/system-prompt.md.hbs +49 -0
- package/assets/agents/_v2/AGENT_CONTEXT.md.hbs +245 -0
- package/assets/agents/_v2/PTC_TOOL_CALLS.md.hbs +35 -0
- package/assets/agents/_v2/coding/SYSTEM.md.hbs +173 -0
- package/assets/agents/_v2/explore.md.hbs +38 -0
- package/assets/agents/_v2/tui/SYSTEM.md.hbs +211 -0
- package/assets/agents/_v2/verifier.md.hbs +32 -0
- package/assets/agents/_v2/work/SYSTEM.md.hbs +186 -0
- package/assets/agents/_v2/worker.md.hbs +27 -0
- package/assets/agents/alran/PERSONA.md +7 -0
- package/assets/agents/alran/features/cron.md.hbs +0 -0
- package/assets/agents/alran/features/delegation.md.hbs +56 -0
- package/assets/agents/alran/features/memory.md.hbs +61 -0
- package/assets/agents/alran/features/recoverable-deletion.md.hbs +10 -0
- package/assets/agents/alran/features/task-management.md.hbs +11 -0
- package/assets/agents/alran/features/web-search.md.hbs +11 -0
- package/assets/agents/alran/modes/coding/online/PERSONA.md.hbs +20 -0
- package/assets/agents/alran/modes/coding/online/SYSTEM.md.hbs +158 -0
- package/assets/agents/alran/modes/work/online/PERSONA.md.hbs +20 -0
- package/assets/agents/alran/modes/work/online/SYSTEM.md.hbs +160 -0
- package/assets/agents/alran/prompt-session-root.md +4 -0
- package/assets/agents/alran/prompt-session-root.md.hbs +4 -0
- package/assets/agents/alran/skills/alran-code-product/SKILL.md +72 -0
- package/assets/agents/alran/skills/alran-code-product/references/account-models.md +64 -0
- package/assets/agents/alran/skills/alran-code-product/references/agents.md +34 -0
- package/assets/agents/alran/skills/alran-code-product/references/extensions.md +46 -0
- package/assets/agents/alran/skills/alran-code-product/references/workflows.md +56 -0
- package/assets/agents/alran/skills/control-in-app-browser/SKILL.md +590 -0
- package/assets/agents/alran/system-prompt.md.hbs +97 -0
- package/assets/agents/builtin-agents.json +1 -0
- package/assets/agents/desktop-task/archive-title/system-en.md +1 -0
- package/assets/agents/desktop-task/checkpoint/system.md +19 -0
- package/assets/agents/desktop-task/output-revision/system.md +1 -0
- package/assets/agents/desktop-task/retry/continuation.md +4 -0
- package/assets/agents/desktop-task/session-title/system.md +41 -0
- package/assets/agents/explore/PERSONA.md +8 -0
- package/assets/agents/explore/agent.md +14 -0
- package/assets/agents/explore/system-prompt.md.hbs +35 -0
- package/assets/agents/greeting.md +61 -0
- package/assets/agents/managed-prompts.json +47 -0
- package/assets/agents/prompt-exemptions.json +36 -0
- package/assets/agents/verifier/PERSONA.md +8 -0
- package/assets/agents/verifier/agent.md +17 -0
- package/assets/agents/verifier/system-prompt.md.hbs +28 -0
- package/assets/agents/worker/PERSONA.md +8 -0
- package/assets/agents/worker/agent.md +18 -0
- package/assets/agents/worker/system-prompt.md.hbs +22 -0
- package/assets/agents/workflow/code-review/review-candidates.md +120 -0
- package/assets/agents/workflow/code-review/reviewer-system.md +75 -0
- package/assets/agents/workflow/goal/budget-limit.md +16 -0
- package/assets/agents/workflow/goal/continuation.md +62 -0
- package/assets/agents/workflow/goal/objective-updated.md +16 -0
- package/assets/agents/workflow/goal/recovery-terminal-audit.md +13 -0
- package/assets/agents/workflow/goal/recovery.md +11 -0
- package/assets/agents/workflow/goal/terminal-audit.md +10 -0
- package/assets/agents/workflow/plan-mode/agent-entry.md +72 -0
- package/assets/agents/workflow/prompt-hook/system.md +0 -0
- package/assets/models-dev-catalog.json.gz +0 -0
- package/assets/prompts/code-review/review-candidates.md +120 -0
- package/assets/prompts/code-review/reviewer-system.md +75 -0
- package/assets/skills/alran-tools-master/SKILL.md +127 -0
- package/assets/skills/code-review/SKILL.md +51 -0
- package/assets/skills/cu-desktop/SKILL.md +255 -0
- package/assets/skills/deep-research/SKILL.md +30 -0
- package/assets/skills/deploy-website/SKILL.md +52 -0
- package/assets/skills/docx/LICENSE +21 -0
- package/assets/skills/docx/SKILL.md +259 -0
- package/assets/skills/docx/assets/styles/academic_styles.xml +250 -0
- package/assets/skills/docx/assets/styles/corporate_styles.xml +284 -0
- package/assets/skills/docx/assets/styles/default_styles.xml +449 -0
- package/assets/skills/docx/assets/xsd/aesthetic-rules.xsd +470 -0
- package/assets/skills/docx/assets/xsd/business-rules.xsd +130 -0
- package/assets/skills/docx/assets/xsd/common-types.xsd +159 -0
- package/assets/skills/docx/assets/xsd/wml-subset.xsd +589 -0
- package/assets/skills/docx/docs/acceptance-checklists/create.md +7 -0
- package/assets/skills/docx/docs/acceptance-checklists/edit.md +6 -0
- package/assets/skills/docx/docs/acceptance-checklists/layout-repair.md +7 -0
- package/assets/skills/docx/docs/acceptance-checklists/template.md +6 -0
- package/assets/skills/docx/docs/acceptance.md +139 -0
- package/assets/skills/docx/docs/anti-patterns.md +14 -0
- package/assets/skills/docx/docs/backends.md +116 -0
- package/assets/skills/docx/docs/evidence.md +73 -0
- package/assets/skills/docx/docs/failure-taxonomy.md +71 -0
- package/assets/skills/docx/docs/index.md +50 -0
- package/assets/skills/docx/docs/rendered-delivery.md +125 -0
- package/assets/skills/docx/docs/router.md +122 -0
- package/assets/skills/docx/docs/tables-and-numbering.md +27 -0
- package/assets/skills/docx/docs/task-apply-template.md +141 -0
- package/assets/skills/docx/docs/task-compare-two-docx.md +48 -0
- package/assets/skills/docx/docs/task-create.md +124 -0
- package/assets/skills/docx/docs/task-edit-fill.md +69 -0
- package/assets/skills/docx/docs/task-read-content.md +148 -0
- package/assets/skills/docx/docs/task-read-rendered.md +78 -0
- package/assets/skills/docx/docs/task-read-structure.md +93 -0
- package/assets/skills/docx/docs/task-repair-layout.md +70 -0
- package/assets/skills/docx/docs/template-dsl.md +32 -0
- package/assets/skills/docx/docs/track-changes.md +15 -0
- package/assets/skills/docx/docs/xml-patch-dsl.md +33 -0
- package/assets/skills/docx/references/cjk_typography.md +357 -0
- package/assets/skills/docx/references/cjk_university_template_guide.md +184 -0
- package/assets/skills/docx/references/comments_guide.md +191 -0
- package/assets/skills/docx/references/design_good_bad_examples.md +829 -0
- package/assets/skills/docx/references/design_principles.md +819 -0
- package/assets/skills/docx/references/openxml_element_order.md +308 -0
- package/assets/skills/docx/references/openxml_encyclopedia_part1.md +4061 -0
- package/assets/skills/docx/references/openxml_encyclopedia_part2.md +2820 -0
- package/assets/skills/docx/references/openxml_encyclopedia_part3.md +3381 -0
- package/assets/skills/docx/references/openxml_namespaces.md +82 -0
- package/assets/skills/docx/references/openxml_units.md +72 -0
- package/assets/skills/docx/references/sample-patch-plans.json +22 -0
- package/assets/skills/docx/references/sample-task-intents.json +5 -0
- package/assets/skills/docx/references/sample-template-manifests.json +21 -0
- package/assets/skills/docx/references/scenario_a_create.md +284 -0
- package/assets/skills/docx/references/scenario_b_edit_content.md +295 -0
- package/assets/skills/docx/references/scenario_c_apply_template.md +456 -0
- package/assets/skills/docx/references/track_changes_guide.md +200 -0
- package/assets/skills/docx/references/troubleshooting.md +506 -0
- package/assets/skills/docx/references/typography_guide.md +294 -0
- package/assets/skills/docx/references/xsd_validation_guide.md +158 -0
- package/assets/skills/docx/scripts/build_patch_plan.py +29 -0
- package/assets/skills/docx/scripts/diff_docx_structure.py +61 -0
- package/assets/skills/docx/scripts/doc_to_docx.ps1 +85 -0
- package/assets/skills/docx/scripts/doc_to_docx.sh +40 -0
- package/assets/skills/docx/scripts/docx_preview.ps1 +76 -0
- package/assets/skills/docx/scripts/docx_preview.sh +37 -0
- package/assets/skills/docx/scripts/docx_to_pdf.py +87 -0
- package/assets/skills/docx/scripts/dotnet/AlranAIDocx.Cli/AlranAIDocx.Cli.csproj +19 -0
- package/assets/skills/docx/scripts/dotnet/AlranAIDocx.Cli/Program.cs +18 -0
- package/assets/skills/docx/scripts/dotnet/AlranAIDocx.Core/AlranAIDocx.Core.csproj +15 -0
- package/assets/skills/docx/scripts/dotnet/AlranAIDocx.Core/Commands/AnalyzeCommand.cs +147 -0
- package/assets/skills/docx/scripts/dotnet/AlranAIDocx.Core/Commands/ApplyTemplateCommand.cs +322 -0
- package/assets/skills/docx/scripts/dotnet/AlranAIDocx.Core/Commands/CreateCommand.cs +324 -0
- package/assets/skills/docx/scripts/dotnet/AlranAIDocx.Core/Commands/DiffCommand.cs +155 -0
- package/assets/skills/docx/scripts/dotnet/AlranAIDocx.Core/Commands/EditContentCommand.cs +487 -0
- package/assets/skills/docx/scripts/dotnet/AlranAIDocx.Core/Commands/FixOrderCommand.cs +108 -0
- package/assets/skills/docx/scripts/dotnet/AlranAIDocx.Core/Commands/MergeRunsCommand.cs +122 -0
- package/assets/skills/docx/scripts/dotnet/AlranAIDocx.Core/Commands/ValidateCommand.cs +107 -0
- package/assets/skills/docx/scripts/dotnet/AlranAIDocx.Core/OpenXml/CommentSynchronizer.cs +169 -0
- package/assets/skills/docx/scripts/dotnet/AlranAIDocx.Core/OpenXml/ElementOrder.cs +80 -0
- package/assets/skills/docx/scripts/dotnet/AlranAIDocx.Core/OpenXml/NamespaceConstants.cs +42 -0
- package/assets/skills/docx/scripts/dotnet/AlranAIDocx.Core/OpenXml/RunMerger.cs +81 -0
- package/assets/skills/docx/scripts/dotnet/AlranAIDocx.Core/OpenXml/StyleAnalyzer.cs +81 -0
- package/assets/skills/docx/scripts/dotnet/AlranAIDocx.Core/OpenXml/TrackChangesHelper.cs +99 -0
- package/assets/skills/docx/scripts/dotnet/AlranAIDocx.Core/OpenXml/UnitConverter.cs +23 -0
- package/assets/skills/docx/scripts/dotnet/AlranAIDocx.Core/Samples/AestheticRecipeSamples.cs +1832 -0
- package/assets/skills/docx/scripts/dotnet/AlranAIDocx.Core/Samples/AestheticRecipeSamples_Batch1.cs +910 -0
- package/assets/skills/docx/scripts/dotnet/AlranAIDocx.Core/Samples/AestheticRecipeSamples_Batch2.cs +999 -0
- package/assets/skills/docx/scripts/dotnet/AlranAIDocx.Core/Samples/AestheticRecipeSamples_Batch3.cs +1048 -0
- package/assets/skills/docx/scripts/dotnet/AlranAIDocx.Core/Samples/AestheticRecipeSamples_Batch4.cs +1038 -0
- package/assets/skills/docx/scripts/dotnet/AlranAIDocx.Core/Samples/CharacterFormattingSamples.cs +1020 -0
- package/assets/skills/docx/scripts/dotnet/AlranAIDocx.Core/Samples/DocumentCreationSamples.cs +1121 -0
- package/assets/skills/docx/scripts/dotnet/AlranAIDocx.Core/Samples/FieldAndTocSamples.cs +624 -0
- package/assets/skills/docx/scripts/dotnet/AlranAIDocx.Core/Samples/FootnoteAndCommentSamples.cs +675 -0
- package/assets/skills/docx/scripts/dotnet/AlranAIDocx.Core/Samples/HeaderFooterSamples.cs +838 -0
- package/assets/skills/docx/scripts/dotnet/AlranAIDocx.Core/Samples/ImageSamples.cs +917 -0
- package/assets/skills/docx/scripts/dotnet/AlranAIDocx.Core/Samples/ListAndNumberingSamples.cs +826 -0
- package/assets/skills/docx/scripts/dotnet/AlranAIDocx.Core/Samples/ParagraphFormattingSamples.cs +1199 -0
- package/assets/skills/docx/scripts/dotnet/AlranAIDocx.Core/Samples/StyleSystemSamples.cs +1487 -0
- package/assets/skills/docx/scripts/dotnet/AlranAIDocx.Core/Samples/TableSamples.cs +1163 -0
- package/assets/skills/docx/scripts/dotnet/AlranAIDocx.Core/Samples/TrackChangesSamples.cs +595 -0
- package/assets/skills/docx/scripts/dotnet/AlranAIDocx.Core/Typography/CjkHelper.cs +39 -0
- package/assets/skills/docx/scripts/dotnet/AlranAIDocx.Core/Typography/FontDefaults.cs +24 -0
- package/assets/skills/docx/scripts/dotnet/AlranAIDocx.Core/Typography/PageSizes.cs +20 -0
- package/assets/skills/docx/scripts/dotnet/AlranAIDocx.Core/Validation/BusinessRuleValidator.cs +224 -0
- package/assets/skills/docx/scripts/dotnet/AlranAIDocx.Core/Validation/GateCheckValidator.cs +148 -0
- package/assets/skills/docx/scripts/dotnet/AlranAIDocx.Core/Validation/ValidationResult.cs +23 -0
- package/assets/skills/docx/scripts/dotnet/AlranAIDocx.Core/Validation/XsdValidator.cs +69 -0
- package/assets/skills/docx/scripts/dotnet/AlranAIDocx.slnx +4 -0
- package/assets/skills/docx/scripts/env_check.ps1 +327 -0
- package/assets/skills/docx/scripts/env_check.sh +340 -0
- package/assets/skills/docx/scripts/extract_docx_text.py +1075 -0
- package/assets/skills/docx/scripts/pack_docx.py +31 -0
- package/assets/skills/docx/scripts/read_docx_structure.py +1032 -0
- package/assets/skills/docx/scripts/render_docx_pages.py +147 -0
- package/assets/skills/docx/scripts/rendered_report.py +609 -0
- package/assets/skills/docx/scripts/setup.ps1 +542 -0
- package/assets/skills/docx/scripts/setup.sh +537 -0
- package/assets/skills/docx/scripts/unpack_docx.py +29 -0
- package/assets/skills/docx/scripts/validate_template_manifest.py +60 -0
- package/assets/skills/docx/scripts/verify_anchor_atomicity.py +87 -0
- package/assets/skills/edit-deployed-website/SKILL.md +27 -0
- package/assets/skills/init/SKILL.md +135 -0
- package/assets/skills/llm-call/SKILL.md +48 -0
- package/assets/skills/llm-call/scripts/llm_call.py +458 -0
- package/assets/skills/pdf/SKILL.md +280 -0
- package/assets/skills/pdf/docs/advanced-reference.md +711 -0
- package/assets/skills/pdf/docs/create-guide.md +437 -0
- package/assets/skills/pdf/docs/design-guide.md +204 -0
- package/assets/skills/pdf/docs/forms-guide.md +462 -0
- package/assets/skills/pdf/docs/html-pdf-spec.md +500 -0
- package/assets/skills/pdf/docs/latex-academic-thesis-guide.md +233 -0
- package/assets/skills/pdf/docs/latex-technical-book-guide.md +112 -0
- package/assets/skills/pdf/docs/pitfalls-index.md +792 -0
- package/assets/skills/pdf/docs/read-guide.md +358 -0
- package/assets/skills/pdf/docs/reformat-guide.md +238 -0
- package/assets/skills/pdf/docs/skill-readme-archive.md +151 -0
- package/assets/skills/pdf/docs/troubleshooting.md +86 -0
- package/assets/skills/pdf/docs/vision-guide.md +188 -0
- package/assets/skills/pdf/scripts/__init__.py +0 -0
- package/assets/skills/pdf/scripts/_pdf_read_lib.py +284 -0
- package/assets/skills/pdf/scripts/fill/__init__.py +0 -0
- package/assets/skills/pdf/scripts/fill/acroform_apply.py +153 -0
- package/assets/skills/pdf/scripts/fill/overlay_apply.py +109 -0
- package/assets/skills/pdf/scripts/lib/__init__.py +0 -0
- package/assets/skills/pdf/scripts/lib/acroform_io.py +170 -0
- package/assets/skills/pdf/scripts/lib/cli_utils.py +41 -0
- package/assets/skills/pdf/scripts/lib/geometry.py +79 -0
- package/assets/skills/pdf/scripts/make.sh +388 -0
- package/assets/skills/pdf/scripts/merge.py +112 -0
- package/assets/skills/pdf/scripts/pdf_inspect/__init__.py +0 -0
- package/assets/skills/pdf/scripts/pdf_inspect/acroform_inspect.py +52 -0
- package/assets/skills/pdf/scripts/pdf_inspect/acroform_probe.py +57 -0
- package/assets/skills/pdf/scripts/pdf_inspect/layout_scan.py +164 -0
- package/assets/skills/pdf/scripts/read_pdf_vision.py +473 -0
- package/assets/skills/pdf/scripts/reformat_parse.py +181 -0
- package/assets/skills/pdf/scripts/render/__init__.py +0 -0
- package/assets/skills/pdf/scripts/render/overlay_preview.py +86 -0
- package/assets/skills/pdf/scripts/render/page_rasterize.py +85 -0
- package/assets/skills/pdf/scripts/render_html.cjs +205 -0
- package/assets/skills/pdf/scripts/validate/__init__.py +0 -0
- package/assets/skills/pdf/scripts/validate/geometry_lint.py +124 -0
- package/assets/skills/pdf/templates/INDEX.md +90 -0
- package/assets/skills/pdf/templates/bilingual-menu-premium/README.md +175 -0
- package/assets/skills/pdf/templates/bilingual-menu-premium/skeleton.html +343 -0
- package/assets/skills/pdf/templates/brand-guide-2page/README.md +140 -0
- package/assets/skills/pdf/templates/brand-guide-2page/skeleton.html +264 -0
- package/assets/skills/pdf/templates/data-viz-report/README.md +234 -0
- package/assets/skills/pdf/templates/data-viz-report/skeleton.html +835 -0
- package/assets/skills/pdf/templates/form-fill-acroform/README.md +195 -0
- package/assets/skills/pdf/templates/form-fill-acroform/field_values.template.json +118 -0
- package/assets/skills/pdf/templates/latex-academic-thesis/README.md +146 -0
- package/assets/skills/pdf/templates/latex-academic-thesis/source.tex +334 -0
- package/assets/skills/pdf/templates/latex-technical-book/README.md +130 -0
- package/assets/skills/pdf/templates/latex-technical-book/README.template-source.md +62 -0
- package/assets/skills/pdf/templates/latex-technical-book/source.tex +439 -0
- package/assets/skills/pdf/templates/multi-article-aggregator/README.md +148 -0
- package/assets/skills/pdf/templates/multi-article-aggregator/pipeline.md +223 -0
- package/assets/skills/pdf/templates/multilang-research-report/README.md +136 -0
- package/assets/skills/pdf/templates/multilang-research-report/skeleton.html +242 -0
- package/assets/skills/pdf/templates/reformat-default/README.md +136 -0
- package/assets/skills/pdf/templates/reformat-default/skeleton.html +204 -0
- package/assets/skills/pdf/templates/translate-preserve-layout/README.md +136 -0
- package/assets/skills/pdf/templates/translate-preserve-layout/skeleton.html +96 -0
- package/assets/skills/pdf/templates/translate-preserve-layout/terminology.template.json +66 -0
- package/assets/skills/pptx/SKILL.md +283 -0
- package/assets/skills/pptx/references/design-system.md +424 -0
- package/assets/skills/pptx/references/editing.md +162 -0
- package/assets/skills/pptx/references/element-map.md +229 -0
- package/assets/skills/pptx/references/pitfalls.md +205 -0
- package/assets/skills/pptx/references/pptxgenjs.md +420 -0
- package/assets/skills/pptx/references/preview-selection-writeback.md +65 -0
- package/assets/skills/pptx/references/python-pptx-recipes.md +63 -0
- package/assets/skills/pptx/references/slide-types.md +413 -0
- package/assets/skills/pptx/scripts/alran-ppt-map.cjs +280 -0
- package/assets/skills/pptx/scripts/audit_pptx.py +708 -0
- package/assets/skills/pptx/scripts/extract_comments.py +468 -0
- package/assets/skills/pptx/scripts/extract_images.py +226 -0
- package/assets/skills/pptx/scripts/extract_pptx.py +285 -0
- package/assets/skills/pptx/scripts/pdf2png.swift +203 -0
- package/assets/skills/pptx/scripts/pptx-screenshot.sh +105 -0
- package/assets/skills/resume-codex/SKILL.md +53 -0
- package/assets/skills/resume-codex/scripts/session-reader.mjs +445 -0
- package/assets/skills/skill-creator/SKILL.md +188 -0
- package/assets/skills/skill-creator/references/anti-patterns.md +149 -0
- package/assets/skills/skill-creator/references/commands-macos-linux.md +38 -0
- package/assets/skills/skill-creator/references/commands-windows-powershell.md +48 -0
- package/assets/skills/skill-creator/references/description-rubric.md +83 -0
- package/assets/skills/skill-creator/references/skill-template.md +101 -0
- package/assets/skills/skill-creator/references/when-to-bundle-scripts.md +139 -0
- package/assets/skills/skill-creator/scripts/lint-skill.js +226 -0
- package/assets/skills/skill-refiner/SKILL.md +137 -0
- package/assets/skills/visual-page/SKILL.md +194 -0
- package/assets/skills/x-link-reader/SKILL.md +108 -0
- package/assets/skills/xlsx/SKILL.md +498 -0
- package/assets/skills/xlsx/docs/advanced-reference.md +410 -0
- package/assets/skills/xlsx/docs/conventions-guide.md +217 -0
- package/assets/skills/xlsx/docs/create-edit-guide.md +410 -0
- package/assets/skills/xlsx/docs/pitfalls-index.md +759 -0
- package/assets/skills/xlsx/docs/raw-xml-escape-hatch.md +201 -0
- package/assets/skills/xlsx/docs/recalc-guide.md +295 -0
- package/assets/skills/xlsx/scripts/office/helpers/__init__.py +0 -0
- package/assets/skills/xlsx/scripts/office/helpers/merge_runs.py +199 -0
- package/assets/skills/xlsx/scripts/office/helpers/simplify_redlines.py +197 -0
- package/assets/skills/xlsx/scripts/office/pack.py +159 -0
- package/assets/skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-chart.xsd +1499 -0
- package/assets/skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-chartDrawing.xsd +146 -0
- package/assets/skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-diagram.xsd +1085 -0
- package/assets/skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-lockedCanvas.xsd +11 -0
- package/assets/skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-main.xsd +3081 -0
- package/assets/skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-picture.xsd +23 -0
- package/assets/skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-spreadsheetDrawing.xsd +185 -0
- package/assets/skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-wordprocessingDrawing.xsd +287 -0
- package/assets/skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/pml.xsd +1676 -0
- package/assets/skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-additionalCharacteristics.xsd +28 -0
- package/assets/skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-bibliography.xsd +144 -0
- package/assets/skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-commonSimpleTypes.xsd +174 -0
- package/assets/skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-customXmlDataProperties.xsd +25 -0
- package/assets/skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-customXmlSchemaProperties.xsd +18 -0
- package/assets/skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesCustom.xsd +59 -0
- package/assets/skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesExtended.xsd +56 -0
- package/assets/skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesVariantTypes.xsd +195 -0
- package/assets/skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-math.xsd +582 -0
- package/assets/skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-relationshipReference.xsd +25 -0
- package/assets/skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/sml.xsd +4439 -0
- package/assets/skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/vml-main.xsd +570 -0
- package/assets/skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/vml-officeDrawing.xsd +509 -0
- package/assets/skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/vml-presentationDrawing.xsd +12 -0
- package/assets/skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/vml-spreadsheetDrawing.xsd +108 -0
- package/assets/skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/vml-wordprocessingDrawing.xsd +96 -0
- package/assets/skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/wml.xsd +3646 -0
- package/assets/skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/xml.xsd +116 -0
- package/assets/skills/xlsx/scripts/office/schemas/ecma/fouth-edition/opc-contentTypes.xsd +42 -0
- package/assets/skills/xlsx/scripts/office/schemas/ecma/fouth-edition/opc-coreProperties.xsd +50 -0
- package/assets/skills/xlsx/scripts/office/schemas/ecma/fouth-edition/opc-digSig.xsd +49 -0
- package/assets/skills/xlsx/scripts/office/schemas/ecma/fouth-edition/opc-relationships.xsd +33 -0
- package/assets/skills/xlsx/scripts/office/schemas/mce/mc.xsd +75 -0
- package/assets/skills/xlsx/scripts/office/schemas/microsoft/wml-2010.xsd +560 -0
- package/assets/skills/xlsx/scripts/office/schemas/microsoft/wml-2012.xsd +67 -0
- package/assets/skills/xlsx/scripts/office/schemas/microsoft/wml-2018.xsd +14 -0
- package/assets/skills/xlsx/scripts/office/schemas/microsoft/wml-cex-2018.xsd +20 -0
- package/assets/skills/xlsx/scripts/office/schemas/microsoft/wml-cid-2016.xsd +13 -0
- package/assets/skills/xlsx/scripts/office/schemas/microsoft/wml-sdtdatahash-2020.xsd +4 -0
- package/assets/skills/xlsx/scripts/office/schemas/microsoft/wml-symex-2015.xsd +8 -0
- package/assets/skills/xlsx/scripts/office/soffice.py +191 -0
- package/assets/skills/xlsx/scripts/office/unpack.py +132 -0
- package/assets/skills/xlsx/scripts/office/validate.py +117 -0
- package/assets/skills/xlsx/scripts/office/validators/__init__.py +15 -0
- package/assets/skills/xlsx/scripts/office/validators/base.py +851 -0
- package/assets/skills/xlsx/scripts/office/validators/docx.py +446 -0
- package/assets/skills/xlsx/scripts/office/validators/pptx.py +275 -0
- package/assets/skills/xlsx/scripts/office/validators/redlining.py +247 -0
- package/assets/skills/xlsx/scripts/recalc.py +450 -0
- package/chunks/account-commands-GW7N3MYC.js +2 -0
- package/chunks/anthropic-63VE6MAE.js +2 -0
- package/chunks/application-WPPTE6LU.js +2 -0
- package/chunks/auth-command-36RMNQZW.js +2 -0
- package/chunks/azure-openai-responses-OIP3KVKJ.js +2 -0
- package/chunks/chunk-2AYWJZ72.js +2 -0
- package/chunks/chunk-2K5H5GA7.js +2 -0
- package/chunks/chunk-2TF6JAQM.js +2 -0
- package/chunks/chunk-3AODGLMF.js +2 -0
- package/chunks/chunk-3GGKARES.js +2 -0
- package/chunks/chunk-4CN3IJFH.js +2 -0
- package/chunks/chunk-4XP5XUIZ.js +2 -0
- package/chunks/chunk-5DQTVSQV.js +131 -0
- package/chunks/chunk-5RIMHTEU.js +207 -0
- package/chunks/chunk-5Y76VFHY.js +2 -0
- package/chunks/chunk-6DOVXX7W.js +2 -0
- package/chunks/chunk-6P4UKHGR.js +2 -0
- package/chunks/chunk-6PFI65C6.js +5 -0
- package/chunks/chunk-6UXSIWCB.js +2 -0
- package/chunks/chunk-7XYOYZX2.js +2 -0
- package/chunks/chunk-AGUSPIUP.js +2 -0
- package/chunks/chunk-BQ3CF3KE.js +2 -0
- package/chunks/chunk-C6LAAFG2.js +30 -0
- package/chunks/chunk-CUG7F2FN.js +2 -0
- package/chunks/chunk-D66ZSHXR.js +2 -0
- package/chunks/chunk-D7MGU75P.js +2 -0
- package/chunks/chunk-DFMYLGVU.js +249 -0
- package/chunks/chunk-EJN3SE5B.js +16 -0
- package/chunks/chunk-F46IELF5.js +2 -0
- package/chunks/chunk-G5MOGPZ3.js +6711 -0
- package/chunks/chunk-GP52JZMY.js +2 -0
- package/chunks/chunk-HNWBFJNO.js +2 -0
- package/chunks/chunk-IC6A323Q.js +2 -0
- package/chunks/chunk-IN2Z5SSJ.js +164 -0
- package/chunks/chunk-JSTSFMGK.js +70 -0
- package/chunks/chunk-K5DTFR6D.js +29 -0
- package/chunks/chunk-LCC45PCZ.js +29 -0
- package/chunks/chunk-LU4RPLJ3.js +2 -0
- package/chunks/chunk-LZJYNT32.js +2 -0
- package/chunks/chunk-MACBL5HF.js +2 -0
- package/chunks/chunk-MPQ6G7LH.js +1085 -0
- package/chunks/chunk-MUXNNOSQ.js +3 -0
- package/chunks/chunk-N5NTXCJI.js +2 -0
- package/chunks/chunk-N6W7ZL26.js +2 -0
- package/chunks/chunk-NBONSNQZ.js +38 -0
- package/chunks/chunk-NMKRNU5O.js +2 -0
- package/chunks/chunk-NVPGGFT3.js +2 -0
- package/chunks/chunk-NZXJAHTO.js +9 -0
- package/chunks/chunk-OTDNOWXG.js +16 -0
- package/chunks/chunk-PCL2CVVE.js +2 -0
- package/chunks/chunk-PXH4SBCS.js +3 -0
- package/chunks/chunk-QKBN5CGI.js +2 -0
- package/chunks/chunk-QPGTKSIQ.js +2 -0
- package/chunks/chunk-R44C5DM6.js +2 -0
- package/chunks/chunk-RLJVY75P.js +28 -0
- package/chunks/chunk-RLND4AYL.js +4 -0
- package/chunks/chunk-SIOLUFGG.js +2 -0
- package/chunks/chunk-TJC4LPRQ.js +2 -0
- package/chunks/chunk-U3RMPDXU.js +2 -0
- package/chunks/chunk-U4PFHJ7Z.js +27 -0
- package/chunks/chunk-UJCAE7SG.js +3 -0
- package/chunks/chunk-V2SB4U4D.js +2 -0
- package/chunks/chunk-VGKKKM2W.js +6 -0
- package/chunks/chunk-VLXX22YO.js +2 -0
- package/chunks/chunk-VUISZDXX.js +24 -0
- package/chunks/chunk-W5ZOLW7T.js +2 -0
- package/chunks/chunk-WHD2XVT2.js +2 -0
- package/chunks/chunk-XLVABFJC.js +9 -0
- package/chunks/chunk-XQK7JM66.js +2 -0
- package/chunks/chunk-XSEU4WQD.js +7 -0
- package/chunks/chunk-XVGPB7TW.js +21 -0
- package/chunks/chunk-Z5HOCNTZ.js +2 -0
- package/chunks/chunk-ZDI22NOK.js +7 -0
- package/chunks/chunk-ZQKVUPKA.js +2 -0
- package/chunks/clipboard-image-PQPC4EHR.js +2 -0
- package/chunks/data-dir-OEPRRIOO.js +2 -0
- package/chunks/dist-VKYZJYR6.js +11 -0
- package/chunks/dist-WGTMUM3E.js +5 -0
- package/chunks/emscripten-module-3WGSFZYF.js +2 -0
- package/chunks/emscripten-module-74WUXTHL.js +2 -0
- package/chunks/emscripten-module-MCN4Y3N4.js +2 -0
- package/chunks/emscripten-module-NEAT5LGD.js +2 -0
- package/chunks/ffi-EFLUAAVX.js +2 -0
- package/chunks/ffi-JIGPPPF7.js +2 -0
- package/chunks/ffi-QKKA5HYI.js +2 -0
- package/chunks/ffi-RLX77WFG.js +2 -0
- package/chunks/google-RCR46TTQ.js +2 -0
- package/chunks/google-vertex-Y26T7YYR.js +2 -0
- package/chunks/install-source-63OVVBMK.js +2 -0
- package/chunks/launcher-2UG3JPYF.js +63 -0
- package/chunks/lifecycle-5IPJRP2V.js +2 -0
- package/chunks/main-7SGOQBHZ.js +13 -0
- package/chunks/mistral-NEBDKUEI.js +3 -0
- package/chunks/module-6F3E5H7Y-FIMLNSCK.js +2 -0
- package/chunks/module-asyncify-R6PWJ6ZV-Q2HJ3NOC.js +2 -0
- package/chunks/multipart-parser-JVSLI2CL.js +2 -0
- package/chunks/network-proxy-AJO7ZW3O.js +2 -0
- package/chunks/openai-codex-responses-L2CIGCKO.js +2 -0
- package/chunks/openai-completions-C4PHW6MD.js +2 -0
- package/chunks/openai-responses-5NVFOW4Y.js +2 -0
- package/chunks/openrouter-BKUGQT7Z.js +2 -0
- package/chunks/otel-DRJM2PIX.js +2 -0
- package/chunks/package-contract-GVXTMJ3N.js +2 -0
- package/chunks/pdfjs-2UOWBGC2.js +107 -0
- package/chunks/photon_rs-MVWYTYTO.js +3 -0
- package/chunks/plugin-command-CIDTOPNB.js +2 -0
- package/chunks/provider-command-UZ7KQFAC.js +2 -0
- package/chunks/questionnaire-bridge-ISQOCYWY.js +2 -0
- package/chunks/run-acp-command-AKDLHKMR.js +59 -0
- package/chunks/run-exec-command-UXTPS7LC.js +15 -0
- package/chunks/skills-command-57TF53NO.js +2 -0
- package/chunks/src-5PSNGHHD.js +2 -0
- package/chunks/src-YZ26EVSY.js +2 -0
- package/chunks/telemetry-3NXMCOVD.js +2 -0
- package/chunks/telemetry-command-CMDERYNN.js +5 -0
- package/chunks/tools-CRJR35HS.js +2 -0
- package/chunks/undici-O4OQVZ6I.js +2 -0
- package/chunks/update-ACFAGV6F.js +14 -0
- package/chunks/update-hint-ED7O67WU.js +3 -0
- package/chunks/wechat-onboard-UWXQW2HT.js +2 -0
- package/cli.js +4 -0
- package/configs/data-minimal.yaml +50 -0
- package/embedded/alran-tools/cli.mjs +4957 -0
- package/embedded/alran-tools/manifest.json +25 -0
- package/emscripten-module.wasm +0 -0
- package/image-preview-worker.js +2 -0
- package/internal-bin/alran-tools +9 -0
- package/internal-bin/alran-tools.cmd +8 -0
- package/matrix-mcp-stdio.js +4 -0
- package/native/darwin/prebuilds/darwin-arm64/darwin-modifiers.node +0 -0
- package/native/darwin/prebuilds/darwin-x64/darwin-modifiers.node +0 -0
- package/native/win32/prebuilds/win32-arm64/win32-console-mode.node +0 -0
- package/native/win32/prebuilds/win32-x64/win32-console-mode.node +0 -0
- package/package.json +38 -4
- package/photon_rs_bg.wasm +0 -0
- package/quickjs-worker.js +152 -0
- package/vendor/java-proxy-agent/build.ts +97 -0
- package/vendor/java-proxy-agent/srt-proxy-agent.jar +0 -0
- package/vendor/seccomp/arm64/apply-seccomp +0 -0
- package/vendor/seccomp/build.ts +74 -0
- package/vendor/seccomp/x64/apply-seccomp +0 -0
- package/vendor/srt-win/arm64/srt-win.exe +0 -0
- package/vendor/srt-win/build.ts +40 -0
- package/vendor/srt-win/x64/srt-win.exe +0 -0
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { createRequire as __alran_cR } from "module"; import { basename as __alran_basename, dirname as __alran_dirname, join as __alran_join } from "path"; import { fileURLToPath as __alran_fileURLToPath, pathToFileURL as __alran_pathToFileURL } from "url"; const __alran_tuiCurrentModuleDir = __alran_dirname(__alran_fileURLToPath(import.meta.url)); const __alran_tuiPackageRoot = __alran_basename(__alran_tuiCurrentModuleDir) === "chunks" ? __alran_dirname(__alran_tuiCurrentModuleDir) : __alran_tuiCurrentModuleDir; const __alran_tuiPackageEntryUrl = __alran_pathToFileURL(__alran_join(__alran_tuiPackageRoot, "cli.js")).href; const require = __alran_cR(__alran_tuiPackageEntryUrl); const __dirname = __alran_tuiPackageRoot;
|
|
2
|
+
import{a as wt,b as Ct,c as mr,e as $n}from"./chunk-XQK7JM66.js";var Qn=mr((Tt,Nn)=>{(function(f,s){typeof Tt==="object"&&typeof Nn!=="undefined"?s(Tt):typeof define==="function"&&define.amd?define(["exports"],s):(f=typeof globalThis!=="undefined"?globalThis:f||self,s(f.WebStreamsPolyfill={}))})(Tt,(function(f){"use strict";function s(){return void 0}function l(e){return typeof e==="object"&&e!==null||typeof e==="function"}const m=s;function d(e,t){try{Object.defineProperty(e,"name",{value:t,configurable:true})}catch(r){}}const R=Promise;const w=Promise.prototype.then;const ue=Promise.reject.bind(R);function P(e){return new R(e)}function S(e){return P(t=>t(e))}function c(e){return ue(e)}function W(e,t,r){return w.call(e,t,r)}function v(e,t,r){W(W(e,t,r),void 0,m)}function M(e,t){v(e,t)}function N(e,t){v(e,void 0,t)}function Q(e,t,r){return W(e,t,r)}function Ce(e){W(e,void 0,m)}let fe=e=>{if(typeof queueMicrotask==="function"){fe=queueMicrotask}else{const t=S(void 0);fe=r=>W(t,r)}return fe(e)};function de(e,t,r){if(typeof e!=="function"){throw new TypeError("Argument is not a function")}return Function.prototype.apply.call(e,t,r)}function J(e,t,r){try{return S(de(e,t,r))}catch(n){return c(n)}}const Rr=16384;class k{constructor(){this._cursor=0;this._size=0;this._front={_elements:[],_next:void 0};this._back=this._front;this._cursor=0;this._size=0}get length(){return this._size}push(t){const r=this._back;let n=r;if(r._elements.length===Rr-1){n={_elements:[],_next:void 0}}r._elements.push(t);if(n!==r){this._back=n;r._next=n}++this._size}shift(){const t=this._front;let r=t;const n=this._cursor;let o=n+1;const a=t._elements;const i=a[n];if(o===Rr){r=t._next;o=0}--this._size;this._cursor=o;if(t!==r){this._front=r}a[n]=void 0;return i}forEach(t){let r=this._cursor;let n=this._front;let o=n._elements;while(r!==o.length||n._next!==void 0){if(r===o.length){n=n._next;o=n._elements;r=0;if(o.length===0){break}}t(o[r]);++r}}peek(){const t=this._front;const r=this._cursor;return t._elements[r]}}const wr=Symbol("[[AbortSteps]]");const Cr=Symbol("[[ErrorSteps]]");const qt=Symbol("[[CancelSteps]]");const At=Symbol("[[PullSteps]]");const Wt=Symbol("[[ReleaseSteps]]");function Tr(e,t){e._ownerReadableStream=t;t._reader=e;if(t._state==="readable"){kt(e)}else if(t._state==="closed"){to(e)}else{Pr(e,t._storedError)}}function Bt(e,t){const r=e._ownerReadableStream;return j(r,t)}function U(e){const t=e._ownerReadableStream;if(t._state==="readable"){Ot(e,new TypeError(`Reader was released and can no longer be used to monitor the stream's closedness`))}else{ro(e,new TypeError(`Reader was released and can no longer be used to monitor the stream's closedness`))}t._readableStreamController[Wt]();t._reader=void 0;e._ownerReadableStream=void 0}function He(e){return new TypeError("Cannot "+e+" a stream using a released reader")}function kt(e){e._closedPromise=P((t,r)=>{e._closedPromise_resolve=t;e._closedPromise_reject=r})}function Pr(e,t){kt(e);Ot(e,t)}function to(e){kt(e);vr(e)}function Ot(e,t){if(e._closedPromise_reject===void 0){return}Ce(e._closedPromise);e._closedPromise_reject(t);e._closedPromise_resolve=void 0;e._closedPromise_reject=void 0}function ro(e,t){Pr(e,t)}function vr(e){if(e._closedPromise_resolve===void 0){return}e._closedPromise_resolve(void 0);e._closedPromise_resolve=void 0;e._closedPromise_reject=void 0}const Er=Number.isFinite||function(e){return typeof e==="number"&&isFinite(e)};const no=Math.trunc||function(e){return e<0?Math.ceil(e):Math.floor(e)};function oo(e){return typeof e==="object"||typeof e==="function"}function L(e,t){if(e!==void 0&&!oo(e)){throw new TypeError(`${t} is not an object.`)}}function O(e,t){if(typeof e!=="function"){throw new TypeError(`${t} is not a function.`)}}function ao(e){return typeof e==="object"&&e!==null||typeof e==="function"}function qr(e,t){if(!ao(e)){throw new TypeError(`${t} is not an object.`)}}function Y(e,t,r){if(e===void 0){throw new TypeError(`Parameter ${t} is required in '${r}'.`)}}function Ft(e,t,r){if(e===void 0){throw new TypeError(`${t} is required in '${r}'.`)}}function zt(e){return Number(e)}function Ar(e){return e===0?0:e}function io(e){return Ar(no(e))}function It(e,t){const r=0;const n=Number.MAX_SAFE_INTEGER;let o=Number(e);o=Ar(o);if(!Er(o)){throw new TypeError(`${t} is not a finite number`)}o=io(o);if(o<r||o>n){throw new TypeError(`${t} is outside the accepted range of ${r} to ${n}, inclusive`)}if(!Er(o)||o===0){return 0}return o}function jt(e,t){if(!ae(e)){throw new TypeError(`${t} is not a ReadableStream.`)}}function Te(e){return new K(e)}function Wr(e,t){e._reader._readRequests.push(t)}function Dt(e,t,r){const n=e._reader;const o=n._readRequests.shift();if(r){o._closeSteps()}else{o._chunkSteps(t)}}function Ge(e){return e._reader._readRequests.length}function Br(e){const t=e._reader;if(t===void 0){return false}if(!ee(t)){return false}return true}class K{constructor(t){Y(t,1,"ReadableStreamDefaultReader");jt(t,"First parameter");if(ie(t)){throw new TypeError("This stream has already been locked for exclusive reading by another reader")}Tr(this,t);this._readRequests=new k}get closed(){if(!ee(this)){return c(xe("closed"))}return this._closedPromise}cancel(t=void 0){if(!ee(this)){return c(xe("cancel"))}if(this._ownerReadableStream===void 0){return c(He("cancel"))}return Bt(this,t)}read(){if(!ee(this)){return c(xe("read"))}if(this._ownerReadableStream===void 0){return c(He("read from"))}let t;let r;const n=P((a,i)=>{t=a;r=i});const o={_chunkSteps:a=>t({value:a,done:false}),_closeSteps:()=>t({value:void 0,done:true}),_errorSteps:a=>r(a)};ze(this,o);return n}releaseLock(){if(!ee(this)){throw xe("releaseLock")}if(this._ownerReadableStream===void 0){return}so(this)}}Object.defineProperties(K.prototype,{cancel:{enumerable:true},read:{enumerable:true},releaseLock:{enumerable:true},closed:{enumerable:true}});d(K.prototype.cancel,"cancel");d(K.prototype.read,"read");d(K.prototype.releaseLock,"releaseLock");if(typeof Symbol.toStringTag==="symbol"){Object.defineProperty(K.prototype,Symbol.toStringTag,{value:"ReadableStreamDefaultReader",configurable:true})}function ee(e){if(!l(e)){return false}if(!Object.prototype.hasOwnProperty.call(e,"_readRequests")){return false}return e instanceof K}function ze(e,t){const r=e._ownerReadableStream;r._disturbed=true;if(r._state==="closed"){t._closeSteps()}else if(r._state==="errored"){t._errorSteps(r._storedError)}else{r._readableStreamController[At](t)}}function so(e){U(e);const t=new TypeError("Reader was released");kr(e,t)}function kr(e,t){const r=e._readRequests;e._readRequests=new k;r.forEach(n=>{n._errorSteps(t)})}function xe(e){return new TypeError(`ReadableStreamDefaultReader.prototype.${e} can only be used on a ReadableStreamDefaultReader`)}const lo=Object.getPrototypeOf(Object.getPrototypeOf(async function*(){}).prototype);class Or{constructor(t,r){this._ongoingPromise=void 0;this._isFinished=false;this._reader=t;this._preventCancel=r}next(){const t=()=>this._nextSteps();this._ongoingPromise=this._ongoingPromise?Q(this._ongoingPromise,t,t):t();return this._ongoingPromise}return(t){const r=()=>this._returnSteps(t);return this._ongoingPromise?Q(this._ongoingPromise,r,r):r()}_nextSteps(){if(this._isFinished){return Promise.resolve({value:void 0,done:true})}const t=this._reader;let r;let n;const o=P((i,u)=>{r=i;n=u});const a={_chunkSteps:i=>{this._ongoingPromise=void 0;fe(()=>r({value:i,done:false}))},_closeSteps:()=>{this._ongoingPromise=void 0;this._isFinished=true;U(t);r({value:void 0,done:true})},_errorSteps:i=>{this._ongoingPromise=void 0;this._isFinished=true;U(t);n(i)}};ze(t,a);return o}_returnSteps(t){if(this._isFinished){return Promise.resolve({value:t,done:true})}this._isFinished=true;const r=this._reader;if(!this._preventCancel){const n=Bt(r,t);U(r);return Q(n,()=>({value:t,done:true}))}U(r);return S({value:t,done:true})}}const Fr={next(){if(!zr(this)){return c(Ir("next"))}return this._asyncIteratorImpl.next()},return(e){if(!zr(this)){return c(Ir("return"))}return this._asyncIteratorImpl.return(e)}};Object.setPrototypeOf(Fr,lo);function uo(e,t){const r=Te(e);const n=new Or(r,t);const o=Object.create(Fr);o._asyncIteratorImpl=n;return o}function zr(e){if(!l(e)){return false}if(!Object.prototype.hasOwnProperty.call(e,"_asyncIteratorImpl")){return false}try{return e._asyncIteratorImpl instanceof Or}catch(t){return false}}function Ir(e){return new TypeError(`ReadableStreamAsyncIterator.${e} can only be used on a ReadableSteamAsyncIterator`)}const jr=Number.isNaN||function(e){return e!==e};var Mt,Lt,$t;function Ie(e){return e.slice()}function Dr(e,t,r,n,o){new Uint8Array(e).set(new Uint8Array(r,n,o),t)}let V=e=>{if(typeof e.transfer==="function"){V=t=>t.transfer()}else if(typeof structuredClone==="function"){V=t=>structuredClone(t,{transfer:[t]})}else{V=t=>t}return V(e)};let te=e=>{if(typeof e.detached==="boolean"){te=t=>t.detached}else{te=t=>t.byteLength===0}return te(e)};function Mr(e,t,r){if(e.slice){return e.slice(t,r)}const n=r-t;const o=new ArrayBuffer(n);Dr(o,0,e,t,n);return o}function Ze(e,t){const r=e[t];if(r===void 0||r===null){return void 0}if(typeof r!=="function"){throw new TypeError(`${String(t)} is not a function`)}return r}function fo(e){const t={[Symbol.iterator]:()=>e.iterator};const r=(async function*(){return yield*t})();const n=r.next;return{iterator:r,nextMethod:n,done:false}}const Nt=($t=(Mt=Symbol.asyncIterator)!==null&&Mt!==void 0?Mt:(Lt=Symbol.for)===null||Lt===void 0?void 0:Lt.call(Symbol,"Symbol.asyncIterator"))!==null&&$t!==void 0?$t:"@@asyncIterator";function Lr(e,t="sync",r){if(r===void 0){if(t==="async"){r=Ze(e,Nt);if(r===void 0){const a=Ze(e,Symbol.iterator);const i=Lr(e,"sync",a);return fo(i)}}else{r=Ze(e,Symbol.iterator)}}if(r===void 0){throw new TypeError("The object is not iterable")}const n=de(r,e,[]);if(!l(n)){throw new TypeError("The iterator method must return an object")}const o=n.next;return{iterator:n,nextMethod:o,done:false}}function co(e){const t=de(e.nextMethod,e.iterator,[]);if(!l(t)){throw new TypeError("The iterator.next() method must return an object")}return t}function ho(e){return Boolean(e.done)}function bo(e){return e.value}function mo(e){if(typeof e!=="number"){return false}if(jr(e)){return false}if(e<0){return false}return true}function $r(e){const t=Mr(e.buffer,e.byteOffset,e.byteOffset+e.byteLength);return new Uint8Array(t)}function Qt(e){const t=e._queue.shift();e._queueTotalSize-=t.size;if(e._queueTotalSize<0){e._queueTotalSize=0}return t.value}function Ut(e,t,r){if(!mo(r)||r===Infinity){throw new RangeError("Size must be a finite, non-NaN, non-negative number.")}e._queue.push({value:t,size:r});e._queueTotalSize+=r}function po(e){const t=e._queue.peek();return t.value}function re(e){e._queue=new k;e._queueTotalSize=0}function Nr(e){return e===DataView}function yo(e){return Nr(e.constructor)}function _o(e){if(Nr(e)){return 1}return e.BYTES_PER_ELEMENT}class ce{constructor(){throw new TypeError("Illegal constructor")}get view(){if(!Yt(this)){throw Zt("view")}return this._view}respond(t){if(!Yt(this)){throw Zt("respond")}Y(t,1,"respond");t=It(t,"First parameter");if(this._associatedReadableByteStreamController===void 0){throw new TypeError("This BYOB request has been invalidated")}if(te(this._view.buffer)){throw new TypeError(`The BYOB request's buffer has been detached and so cannot be used as a response`)}et(this._associatedReadableByteStreamController,t)}respondWithNewView(t){if(!Yt(this)){throw Zt("respondWithNewView")}Y(t,1,"respondWithNewView");if(!ArrayBuffer.isView(t)){throw new TypeError("You can only respond with array buffer views")}if(this._associatedReadableByteStreamController===void 0){throw new TypeError("This BYOB request has been invalidated")}if(te(t.buffer)){throw new TypeError("The given view's buffer has been detached and so cannot be used as a response")}tt(this._associatedReadableByteStreamController,t)}}Object.defineProperties(ce.prototype,{respond:{enumerable:true},respondWithNewView:{enumerable:true},view:{enumerable:true}});d(ce.prototype.respond,"respond");d(ce.prototype.respondWithNewView,"respondWithNewView");if(typeof Symbol.toStringTag==="symbol"){Object.defineProperty(ce.prototype,Symbol.toStringTag,{value:"ReadableStreamBYOBRequest",configurable:true})}class H{constructor(){throw new TypeError("Illegal constructor")}get byobRequest(){if(!he(this)){throw De("byobRequest")}return xt(this)}get desiredSize(){if(!he(this)){throw De("desiredSize")}return Jr(this)}close(){if(!he(this)){throw De("close")}if(this._closeRequested){throw new TypeError("The stream has already been closed; do not close it again!")}const t=this._controlledReadableByteStream._state;if(t!=="readable"){throw new TypeError(`The stream (in ${t} state) is not in the readable state and cannot be closed`)}je(this)}enqueue(t){if(!he(this)){throw De("enqueue")}Y(t,1,"enqueue");if(!ArrayBuffer.isView(t)){throw new TypeError("chunk must be an array buffer view")}if(t.byteLength===0){throw new TypeError("chunk must have non-zero byteLength")}if(t.buffer.byteLength===0){throw new TypeError(`chunk's buffer must have non-zero byteLength`)}if(this._closeRequested){throw new TypeError("stream is closed or draining")}const r=this._controlledReadableByteStream._state;if(r!=="readable"){throw new TypeError(`The stream (in ${r} state) is not in the readable state and cannot be enqueued to`)}Ke(this,t)}error(t=void 0){if(!he(this)){throw De("error")}F(this,t)}[qt](t){Qr(this);re(this);const r=this._cancelAlgorithm(t);Je(this);return r}[At](t){const r=this._controlledReadableByteStream;if(this._queueTotalSize>0){Xr(this,t);return}const n=this._autoAllocateChunkSize;if(n!==void 0){let o;try{o=new ArrayBuffer(n)}catch(i){t._errorSteps(i);return}const a={buffer:o,bufferByteLength:n,byteOffset:0,byteLength:n,bytesFilled:0,minimumFill:1,elementSize:1,viewConstructor:Uint8Array,readerType:"default"};this._pendingPullIntos.push(a)}Wr(r,t);be(this)}[Wt](){if(this._pendingPullIntos.length>0){const t=this._pendingPullIntos.peek();t.readerType="none";this._pendingPullIntos=new k;this._pendingPullIntos.push(t)}}}Object.defineProperties(H.prototype,{close:{enumerable:true},enqueue:{enumerable:true},error:{enumerable:true},byobRequest:{enumerable:true},desiredSize:{enumerable:true}});d(H.prototype.close,"close");d(H.prototype.enqueue,"enqueue");d(H.prototype.error,"error");if(typeof Symbol.toStringTag==="symbol"){Object.defineProperty(H.prototype,Symbol.toStringTag,{value:"ReadableByteStreamController",configurable:true})}function he(e){if(!l(e)){return false}if(!Object.prototype.hasOwnProperty.call(e,"_controlledReadableByteStream")){return false}return e instanceof H}function Yt(e){if(!l(e)){return false}if(!Object.prototype.hasOwnProperty.call(e,"_associatedReadableByteStreamController")){return false}return e instanceof ce}function be(e){const t=Co(e);if(!t){return}if(e._pulling){e._pullAgain=true;return}e._pulling=true;const r=e._pullAlgorithm();v(r,()=>{e._pulling=false;if(e._pullAgain){e._pullAgain=false;be(e)}return null},n=>{F(e,n);return null})}function Qr(e){Ht(e);e._pendingPullIntos=new k}function Vt(e,t){let r=false;if(e._state==="closed"){r=true}const n=Ur(t);if(t.readerType==="default"){Dt(e,n,r)}else{Ao(e,n,r)}}function Ur(e){const t=e.bytesFilled;const r=e.elementSize;return new e.viewConstructor(e.buffer,e.byteOffset,t/r)}function Xe(e,t,r,n){e._queue.push({buffer:t,byteOffset:r,byteLength:n});e._queueTotalSize+=n}function Yr(e,t,r,n){let o;try{o=Mr(t,r,r+n)}catch(a){F(e,a);throw a}Xe(e,o,0,n)}function Vr(e,t){if(t.bytesFilled>0){Yr(e,t.buffer,t.byteOffset,t.bytesFilled)}Pe(e)}function Hr(e,t){const r=Math.min(e._queueTotalSize,t.byteLength-t.bytesFilled);const n=t.bytesFilled+r;let o=r;let a=false;const i=n%t.elementSize;const u=n-i;if(u>=t.minimumFill){o=u-t.bytesFilled;a=true}const p=e._queue;while(o>0){const h=p.peek();const y=Math.min(o,h.byteLength);const _=t.byteOffset+t.bytesFilled;Dr(t.buffer,_,h.buffer,h.byteOffset,y);if(h.byteLength===y){p.shift()}else{h.byteOffset+=y;h.byteLength-=y}e._queueTotalSize-=y;Gr(e,y,t);o-=y}return a}function Gr(e,t,r){r.bytesFilled+=t}function xr(e){if(e._queueTotalSize===0&&e._closeRequested){Je(e);Ue(e._controlledReadableByteStream)}else{be(e)}}function Ht(e){if(e._byobRequest===null){return}e._byobRequest._associatedReadableByteStreamController=void 0;e._byobRequest._view=null;e._byobRequest=null}function Gt(e){while(e._pendingPullIntos.length>0){if(e._queueTotalSize===0){return}const t=e._pendingPullIntos.peek();if(Hr(e,t)){Pe(e);Vt(e._controlledReadableByteStream,t)}}}function So(e){const t=e._controlledReadableByteStream._reader;while(t._readRequests.length>0){if(e._queueTotalSize===0){return}const r=t._readRequests.shift();Xr(e,r)}}function go(e,t,r,n){const o=e._controlledReadableByteStream;const a=t.constructor;const i=_o(a);const{byteOffset:u,byteLength:p}=t;const h=r*i;let y;try{y=V(t.buffer)}catch(C){n._errorSteps(C);return}const _={buffer:y,bufferByteLength:y.byteLength,byteOffset:u,byteLength:p,bytesFilled:0,minimumFill:h,elementSize:i,viewConstructor:a,readerType:"byob"};if(e._pendingPullIntos.length>0){e._pendingPullIntos.push(_);tn(o,n);return}if(o._state==="closed"){const C=new a(_.buffer,_.byteOffset,0);n._closeSteps(C);return}if(e._queueTotalSize>0){if(Hr(e,_)){const C=Ur(_);xr(e);n._chunkSteps(C);return}if(e._closeRequested){const C=new TypeError("Insufficient bytes to fill elements in the given buffer");F(e,C);n._errorSteps(C);return}}e._pendingPullIntos.push(_);tn(o,n);be(e)}function Ro(e,t){if(t.readerType==="none"){Pe(e)}const r=e._controlledReadableByteStream;if(Xt(r)){while(rn(r)>0){const n=Pe(e);Vt(r,n)}}}function wo(e,t,r){Gr(e,t,r);if(r.readerType==="none"){Vr(e,r);Gt(e);return}if(r.bytesFilled<r.minimumFill){return}Pe(e);const n=r.bytesFilled%r.elementSize;if(n>0){const o=r.byteOffset+r.bytesFilled;Yr(e,r.buffer,o-n,n)}r.bytesFilled-=n;Vt(e._controlledReadableByteStream,r);Gt(e)}function Zr(e,t){const r=e._pendingPullIntos.peek();Ht(e);const n=e._controlledReadableByteStream._state;if(n==="closed"){Ro(e,r)}else{wo(e,t,r)}be(e)}function Pe(e){const t=e._pendingPullIntos.shift();return t}function Co(e){const t=e._controlledReadableByteStream;if(t._state!=="readable"){return false}if(e._closeRequested){return false}if(!e._started){return false}if(Br(t)&&Ge(t)>0){return true}if(Xt(t)&&rn(t)>0){return true}const r=Jr(e);if(r>0){return true}return false}function Je(e){e._pullAlgorithm=void 0;e._cancelAlgorithm=void 0}function je(e){const t=e._controlledReadableByteStream;if(e._closeRequested||t._state!=="readable"){return}if(e._queueTotalSize>0){e._closeRequested=true;return}if(e._pendingPullIntos.length>0){const r=e._pendingPullIntos.peek();if(r.bytesFilled%r.elementSize!==0){const n=new TypeError("Insufficient bytes to fill elements in the given buffer");F(e,n);throw n}}Je(e);Ue(t)}function Ke(e,t){const r=e._controlledReadableByteStream;if(e._closeRequested||r._state!=="readable"){return}const{buffer:n,byteOffset:o,byteLength:a}=t;if(te(n)){throw new TypeError("chunk's buffer is detached and so cannot be enqueued")}const i=V(n);if(e._pendingPullIntos.length>0){const u=e._pendingPullIntos.peek();if(te(u.buffer)){throw new TypeError("The BYOB request's buffer has been detached and so cannot be filled with an enqueued chunk")}Ht(e);u.buffer=V(u.buffer);if(u.readerType==="none"){Vr(e,u)}}if(Br(r)){So(e);if(Ge(r)===0){Xe(e,i,o,a)}else{if(e._pendingPullIntos.length>0){Pe(e)}const u=new Uint8Array(i,o,a);Dt(r,u,false)}}else if(Xt(r)){Xe(e,i,o,a);Gt(e)}else{Xe(e,i,o,a)}be(e)}function F(e,t){const r=e._controlledReadableByteStream;if(r._state!=="readable"){return}Qr(e);re(e);Je(e);En(r,t)}function Xr(e,t){const r=e._queue.shift();e._queueTotalSize-=r.byteLength;xr(e);const n=new Uint8Array(r.buffer,r.byteOffset,r.byteLength);t._chunkSteps(n)}function xt(e){if(e._byobRequest===null&&e._pendingPullIntos.length>0){const t=e._pendingPullIntos.peek();const r=new Uint8Array(t.buffer,t.byteOffset+t.bytesFilled,t.byteLength-t.bytesFilled);const n=Object.create(ce.prototype);Po(n,e,r);e._byobRequest=n}return e._byobRequest}function Jr(e){const t=e._controlledReadableByteStream._state;if(t==="errored"){return null}if(t==="closed"){return 0}return e._strategyHWM-e._queueTotalSize}function et(e,t){const r=e._pendingPullIntos.peek();const n=e._controlledReadableByteStream._state;if(n==="closed"){if(t!==0){throw new TypeError("bytesWritten must be 0 when calling respond() on a closed stream")}}else{if(t===0){throw new TypeError("bytesWritten must be greater than 0 when calling respond() on a readable stream")}if(r.bytesFilled+t>r.byteLength){throw new RangeError("bytesWritten out of range")}}r.buffer=V(r.buffer);Zr(e,t)}function tt(e,t){const r=e._pendingPullIntos.peek();const n=e._controlledReadableByteStream._state;if(n==="closed"){if(t.byteLength!==0){throw new TypeError("The view's length must be 0 when calling respondWithNewView() on a closed stream")}}else{if(t.byteLength===0){throw new TypeError("The view's length must be greater than 0 when calling respondWithNewView() on a readable stream")}}if(r.byteOffset+r.bytesFilled!==t.byteOffset){throw new RangeError("The region specified by view does not match byobRequest")}if(r.bufferByteLength!==t.buffer.byteLength){throw new RangeError("The buffer of view has different capacity than byobRequest")}if(r.bytesFilled+t.byteLength>r.byteLength){throw new RangeError("The region specified by view is larger than byobRequest")}const o=t.byteLength;r.buffer=V(t.buffer);Zr(e,o)}function Kr(e,t,r,n,o,a,i){t._controlledReadableByteStream=e;t._pullAgain=false;t._pulling=false;t._byobRequest=null;t._queue=t._queueTotalSize=void 0;re(t);t._closeRequested=false;t._started=false;t._strategyHWM=a;t._pullAlgorithm=n;t._cancelAlgorithm=o;t._autoAllocateChunkSize=i;t._pendingPullIntos=new k;e._readableStreamController=t;const u=r();v(S(u),()=>{t._started=true;be(t);return null},p=>{F(t,p);return null})}function To(e,t,r){const n=Object.create(H.prototype);let o;let a;let i;if(t.start!==void 0){o=()=>t.start(n)}else{o=()=>void 0}if(t.pull!==void 0){a=()=>t.pull(n)}else{a=()=>S(void 0)}if(t.cancel!==void 0){i=p=>t.cancel(p)}else{i=()=>S(void 0)}const u=t.autoAllocateChunkSize;if(u===0){throw new TypeError("autoAllocateChunkSize must be greater than 0")}Kr(e,n,o,a,i,r,u)}function Po(e,t,r){e._associatedReadableByteStreamController=t;e._view=r}function Zt(e){return new TypeError(`ReadableStreamBYOBRequest.prototype.${e} can only be used on a ReadableStreamBYOBRequest`)}function De(e){return new TypeError(`ReadableByteStreamController.prototype.${e} can only be used on a ReadableByteStreamController`)}function vo(e,t){L(e,t);const r=e===null||e===void 0?void 0:e.mode;return{mode:r===void 0?void 0:Eo(r,`${t} has member 'mode' that`)}}function Eo(e,t){e=`${e}`;if(e!=="byob"){throw new TypeError(`${t} '${e}' is not a valid enumeration value for ReadableStreamReaderMode`)}return e}function qo(e,t){var r;L(e,t);const n=(r=e===null||e===void 0?void 0:e.min)!==null&&r!==void 0?r:1;return{min:It(n,`${t} has member 'min' that`)}}function en(e){return new ne(e)}function tn(e,t){e._reader._readIntoRequests.push(t)}function Ao(e,t,r){const n=e._reader;const o=n._readIntoRequests.shift();if(r){o._closeSteps(t)}else{o._chunkSteps(t)}}function rn(e){return e._reader._readIntoRequests.length}function Xt(e){const t=e._reader;if(t===void 0){return false}if(!me(t)){return false}return true}class ne{constructor(t){Y(t,1,"ReadableStreamBYOBReader");jt(t,"First parameter");if(ie(t)){throw new TypeError("This stream has already been locked for exclusive reading by another reader")}if(!he(t._readableStreamController)){throw new TypeError("Cannot construct a ReadableStreamBYOBReader for a stream not constructed with a byte source")}Tr(this,t);this._readIntoRequests=new k}get closed(){if(!me(this)){return c(rt("closed"))}return this._closedPromise}cancel(t=void 0){if(!me(this)){return c(rt("cancel"))}if(this._ownerReadableStream===void 0){return c(He("cancel"))}return Bt(this,t)}read(t,r={}){if(!me(this)){return c(rt("read"))}if(!ArrayBuffer.isView(t)){return c(new TypeError("view must be an array buffer view"))}if(t.byteLength===0){return c(new TypeError("view must have non-zero byteLength"))}if(t.buffer.byteLength===0){return c(new TypeError(`view's buffer must have non-zero byteLength`))}if(te(t.buffer)){return c(new TypeError("view's buffer has been detached"))}let n;try{n=qo(r,"options")}catch(h){return c(h)}const o=n.min;if(o===0){return c(new TypeError("options.min must be greater than 0"))}if(!yo(t)){if(o>t.length){return c(new RangeError("options.min must be less than or equal to view's length"))}}else if(o>t.byteLength){return c(new RangeError("options.min must be less than or equal to view's byteLength"))}if(this._ownerReadableStream===void 0){return c(He("read from"))}let a;let i;const u=P((h,y)=>{a=h;i=y});const p={_chunkSteps:h=>a({value:h,done:false}),_closeSteps:h=>a({value:h,done:true}),_errorSteps:h=>i(h)};nn(this,t,o,p);return u}releaseLock(){if(!me(this)){throw rt("releaseLock")}if(this._ownerReadableStream===void 0){return}Wo(this)}}Object.defineProperties(ne.prototype,{cancel:{enumerable:true},read:{enumerable:true},releaseLock:{enumerable:true},closed:{enumerable:true}});d(ne.prototype.cancel,"cancel");d(ne.prototype.read,"read");d(ne.prototype.releaseLock,"releaseLock");if(typeof Symbol.toStringTag==="symbol"){Object.defineProperty(ne.prototype,Symbol.toStringTag,{value:"ReadableStreamBYOBReader",configurable:true})}function me(e){if(!l(e)){return false}if(!Object.prototype.hasOwnProperty.call(e,"_readIntoRequests")){return false}return e instanceof ne}function nn(e,t,r,n){const o=e._ownerReadableStream;o._disturbed=true;if(o._state==="errored"){n._errorSteps(o._storedError)}else{go(o._readableStreamController,t,r,n)}}function Wo(e){U(e);const t=new TypeError("Reader was released");on(e,t)}function on(e,t){const r=e._readIntoRequests;e._readIntoRequests=new k;r.forEach(n=>{n._errorSteps(t)})}function rt(e){return new TypeError(`ReadableStreamBYOBReader.prototype.${e} can only be used on a ReadableStreamBYOBReader`)}function Me(e,t){const{highWaterMark:r}=e;if(r===void 0){return t}if(jr(r)||r<0){throw new RangeError("Invalid highWaterMark")}return r}function nt(e){const{size:t}=e;if(!t){return()=>1}return t}function ot(e,t){L(e,t);const r=e===null||e===void 0?void 0:e.highWaterMark;const n=e===null||e===void 0?void 0:e.size;return{highWaterMark:r===void 0?void 0:zt(r),size:n===void 0?void 0:Bo(n,`${t} has member 'size' that`)}}function Bo(e,t){O(e,t);return r=>zt(e(r))}function ko(e,t){L(e,t);const r=e===null||e===void 0?void 0:e.abort;const n=e===null||e===void 0?void 0:e.close;const o=e===null||e===void 0?void 0:e.start;const a=e===null||e===void 0?void 0:e.type;const i=e===null||e===void 0?void 0:e.write;return{abort:r===void 0?void 0:Oo(r,e,`${t} has member 'abort' that`),close:n===void 0?void 0:Fo(n,e,`${t} has member 'close' that`),start:o===void 0?void 0:zo(o,e,`${t} has member 'start' that`),write:i===void 0?void 0:Io(i,e,`${t} has member 'write' that`),type:a}}function Oo(e,t,r){O(e,r);return n=>J(e,t,[n])}function Fo(e,t,r){O(e,r);return()=>J(e,t,[])}function zo(e,t,r){O(e,r);return n=>de(e,t,[n])}function Io(e,t,r){O(e,r);return(n,o)=>J(e,t,[n,o])}function an(e,t){if(!ve(e)){throw new TypeError(`${t} is not a WritableStream.`)}}function jo(e){if(typeof e!=="object"||e===null){return false}try{return typeof e.aborted==="boolean"}catch(t){return false}}const Do=typeof AbortController==="function";function Mo(){if(Do){return new AbortController}return void 0}class oe{constructor(t={},r={}){if(t===void 0){t=null}else{qr(t,"First parameter")}const n=ot(r,"Second parameter");const o=ko(t,"First parameter");ln(this);const a=o.type;if(a!==void 0){throw new RangeError("Invalid type is specified")}const i=nt(n);const u=Me(n,1);Ko(this,o,u,i)}get locked(){if(!ve(this)){throw ut("locked")}return Ee(this)}abort(t=void 0){if(!ve(this)){return c(ut("abort"))}if(Ee(this)){return c(new TypeError("Cannot abort a stream that already has a writer"))}return at(this,t)}close(){if(!ve(this)){return c(ut("close"))}if(Ee(this)){return c(new TypeError("Cannot close a stream that already has a writer"))}if($(this)){return c(new TypeError("Cannot close an already-closing stream"))}return un(this)}getWriter(){if(!ve(this)){throw ut("getWriter")}return sn(this)}}Object.defineProperties(oe.prototype,{abort:{enumerable:true},close:{enumerable:true},getWriter:{enumerable:true},locked:{enumerable:true}});d(oe.prototype.abort,"abort");d(oe.prototype.close,"close");d(oe.prototype.getWriter,"getWriter");if(typeof Symbol.toStringTag==="symbol"){Object.defineProperty(oe.prototype,Symbol.toStringTag,{value:"WritableStream",configurable:true})}function sn(e){return new G(e)}function Lo(e,t,r,n,o=1,a=()=>1){const i=Object.create(oe.prototype);ln(i);const u=Object.create(qe.prototype);mn(i,u,e,t,r,n,o,a);return i}function ln(e){e._state="writable";e._storedError=void 0;e._writer=void 0;e._writableStreamController=void 0;e._writeRequests=new k;e._inFlightWriteRequest=void 0;e._closeRequest=void 0;e._inFlightCloseRequest=void 0;e._pendingAbortRequest=void 0;e._backpressure=false}function ve(e){if(!l(e)){return false}if(!Object.prototype.hasOwnProperty.call(e,"_writableStreamController")){return false}return e instanceof oe}function Ee(e){if(e._writer===void 0){return false}return true}function at(e,t){var r;if(e._state==="closed"||e._state==="errored"){return S(void 0)}e._writableStreamController._abortReason=t;(r=e._writableStreamController._abortController)===null||r===void 0?void 0:r.abort(t);const n=e._state;if(n==="closed"||n==="errored"){return S(void 0)}if(e._pendingAbortRequest!==void 0){return e._pendingAbortRequest._promise}let o=false;if(n==="erroring"){o=true;t=void 0}const a=P((i,u)=>{e._pendingAbortRequest={_promise:void 0,_resolve:i,_reject:u,_reason:t,_wasAlreadyErroring:o}});e._pendingAbortRequest._promise=a;if(!o){Kt(e,t)}return a}function un(e){const t=e._state;if(t==="closed"||t==="errored"){return c(new TypeError(`The stream (in ${t} state) is not in the writable state and cannot be closed`))}const r=P((o,a)=>{const i={_resolve:o,_reject:a};e._closeRequest=i});const n=e._writer;if(n!==void 0&&e._backpressure&&t==="writable"){sr(n)}ea(e._writableStreamController);return r}function $o(e){const t=P((r,n)=>{const o={_resolve:r,_reject:n};e._writeRequests.push(o)});return t}function Jt(e,t){const r=e._state;if(r==="writable"){Kt(e,t);return}er(e)}function Kt(e,t){const r=e._writableStreamController;e._state="erroring";e._storedError=t;const n=e._writer;if(n!==void 0){dn(n,t)}if(!Vo(e)&&r._started){er(e)}}function er(e){e._state="errored";e._writableStreamController[Cr]();const t=e._storedError;e._writeRequests.forEach(o=>{o._reject(t)});e._writeRequests=new k;if(e._pendingAbortRequest===void 0){it(e);return}const r=e._pendingAbortRequest;e._pendingAbortRequest=void 0;if(r._wasAlreadyErroring){r._reject(t);it(e);return}const n=e._writableStreamController[wr](r._reason);v(n,()=>{r._resolve();it(e);return null},o=>{r._reject(o);it(e);return null})}function No(e){e._inFlightWriteRequest._resolve(void 0);e._inFlightWriteRequest=void 0}function Qo(e,t){e._inFlightWriteRequest._reject(t);e._inFlightWriteRequest=void 0;Jt(e,t)}function Uo(e){e._inFlightCloseRequest._resolve(void 0);e._inFlightCloseRequest=void 0;const t=e._state;if(t==="erroring"){e._storedError=void 0;if(e._pendingAbortRequest!==void 0){e._pendingAbortRequest._resolve();e._pendingAbortRequest=void 0}}e._state="closed";const r=e._writer;if(r!==void 0){Sn(r)}}function Yo(e,t){e._inFlightCloseRequest._reject(t);e._inFlightCloseRequest=void 0;if(e._pendingAbortRequest!==void 0){e._pendingAbortRequest._reject(t);e._pendingAbortRequest=void 0}Jt(e,t)}function $(e){if(e._closeRequest===void 0&&e._inFlightCloseRequest===void 0){return false}return true}function Vo(e){if(e._inFlightWriteRequest===void 0&&e._inFlightCloseRequest===void 0){return false}return true}function Ho(e){e._inFlightCloseRequest=e._closeRequest;e._closeRequest=void 0}function Go(e){e._inFlightWriteRequest=e._writeRequests.shift()}function it(e){if(e._closeRequest!==void 0){e._closeRequest._reject(e._storedError);e._closeRequest=void 0}const t=e._writer;if(t!==void 0){ar(t,e._storedError)}}function tr(e,t){const r=e._writer;if(r!==void 0&&t!==e._backpressure){if(t){sa(r)}else{sr(r)}}e._backpressure=t}class G{constructor(t){Y(t,1,"WritableStreamDefaultWriter");an(t,"First parameter");if(Ee(t)){throw new TypeError("This stream has already been locked for exclusive writing by another writer")}this._ownerWritableStream=t;t._writer=this;const r=t._state;if(r==="writable"){if(!$(t)&&t._backpressure){dt(this)}else{gn(this)}ft(this)}else if(r==="erroring"){ir(this,t._storedError);ft(this)}else if(r==="closed"){gn(this);aa(this)}else{const n=t._storedError;ir(this,n);_n(this,n)}}get closed(){if(!pe(this)){return c(ye("closed"))}return this._closedPromise}get desiredSize(){if(!pe(this)){throw ye("desiredSize")}if(this._ownerWritableStream===void 0){throw $e("desiredSize")}return Jo(this)}get ready(){if(!pe(this)){return c(ye("ready"))}return this._readyPromise}abort(t=void 0){if(!pe(this)){return c(ye("abort"))}if(this._ownerWritableStream===void 0){return c($e("abort"))}return xo(this,t)}close(){if(!pe(this)){return c(ye("close"))}const t=this._ownerWritableStream;if(t===void 0){return c($e("close"))}if($(t)){return c(new TypeError("Cannot close an already-closing stream"))}return fn(this)}releaseLock(){if(!pe(this)){throw ye("releaseLock")}const t=this._ownerWritableStream;if(t===void 0){return}cn(this)}write(t=void 0){if(!pe(this)){return c(ye("write"))}if(this._ownerWritableStream===void 0){return c($e("write to"))}return hn(this,t)}}Object.defineProperties(G.prototype,{abort:{enumerable:true},close:{enumerable:true},releaseLock:{enumerable:true},write:{enumerable:true},closed:{enumerable:true},desiredSize:{enumerable:true},ready:{enumerable:true}});d(G.prototype.abort,"abort");d(G.prototype.close,"close");d(G.prototype.releaseLock,"releaseLock");d(G.prototype.write,"write");if(typeof Symbol.toStringTag==="symbol"){Object.defineProperty(G.prototype,Symbol.toStringTag,{value:"WritableStreamDefaultWriter",configurable:true})}function pe(e){if(!l(e)){return false}if(!Object.prototype.hasOwnProperty.call(e,"_ownerWritableStream")){return false}return e instanceof G}function xo(e,t){const r=e._ownerWritableStream;return at(r,t)}function fn(e){const t=e._ownerWritableStream;return un(t)}function Zo(e){const t=e._ownerWritableStream;const r=t._state;if($(t)||r==="closed"){return S(void 0)}if(r==="errored"){return c(t._storedError)}return fn(e)}function Xo(e,t){if(e._closedPromiseState==="pending"){ar(e,t)}else{ia(e,t)}}function dn(e,t){if(e._readyPromiseState==="pending"){Rn(e,t)}else{la(e,t)}}function Jo(e){const t=e._ownerWritableStream;const r=t._state;if(r==="errored"||r==="erroring"){return null}if(r==="closed"){return 0}return pn(t._writableStreamController)}function cn(e){const t=e._ownerWritableStream;const r=new TypeError(`Writer was released and can no longer be used to monitor the stream's closedness`);dn(e,r);Xo(e,r);t._writer=void 0;e._ownerWritableStream=void 0}function hn(e,t){const r=e._ownerWritableStream;const n=r._writableStreamController;const o=ta(n,t);if(r!==e._ownerWritableStream){return c($e("write to"))}const a=r._state;if(a==="errored"){return c(r._storedError)}if($(r)||a==="closed"){return c(new TypeError("The stream is closing or closed and cannot be written to"))}if(a==="erroring"){return c(r._storedError)}const i=$o(r);ra(n,t,o);return i}const bn={};class qe{constructor(){throw new TypeError("Illegal constructor")}get abortReason(){if(!rr(this)){throw or("abortReason")}return this._abortReason}get signal(){if(!rr(this)){throw or("signal")}if(this._abortController===void 0){throw new TypeError("WritableStreamDefaultController.prototype.signal is not supported")}return this._abortController.signal}error(t=void 0){if(!rr(this)){throw or("error")}const r=this._controlledWritableStream._state;if(r!=="writable"){return}yn(this,t)}[wr](t){const r=this._abortAlgorithm(t);st(this);return r}[Cr](){re(this)}}Object.defineProperties(qe.prototype,{abortReason:{enumerable:true},signal:{enumerable:true},error:{enumerable:true}});if(typeof Symbol.toStringTag==="symbol"){Object.defineProperty(qe.prototype,Symbol.toStringTag,{value:"WritableStreamDefaultController",configurable:true})}function rr(e){if(!l(e)){return false}if(!Object.prototype.hasOwnProperty.call(e,"_controlledWritableStream")){return false}return e instanceof qe}function mn(e,t,r,n,o,a,i,u){t._controlledWritableStream=e;e._writableStreamController=t;t._queue=void 0;t._queueTotalSize=void 0;re(t);t._abortReason=void 0;t._abortController=Mo();t._started=false;t._strategySizeAlgorithm=u;t._strategyHWM=i;t._writeAlgorithm=n;t._closeAlgorithm=o;t._abortAlgorithm=a;const p=nr(t);tr(e,p);const h=r();const y=S(h);v(y,()=>{t._started=true;lt(t);return null},_=>{t._started=true;Jt(e,_);return null})}function Ko(e,t,r,n){const o=Object.create(qe.prototype);let a;let i;let u;let p;if(t.start!==void 0){a=()=>t.start(o)}else{a=()=>void 0}if(t.write!==void 0){i=h=>t.write(h,o)}else{i=()=>S(void 0)}if(t.close!==void 0){u=()=>t.close()}else{u=()=>S(void 0)}if(t.abort!==void 0){p=h=>t.abort(h)}else{p=()=>S(void 0)}mn(e,o,a,i,u,p,r,n)}function st(e){e._writeAlgorithm=void 0;e._closeAlgorithm=void 0;e._abortAlgorithm=void 0;e._strategySizeAlgorithm=void 0}function ea(e){Ut(e,bn,0);lt(e)}function ta(e,t){try{return e._strategySizeAlgorithm(t)}catch(r){Le(e,r);return 1}}function pn(e){return e._strategyHWM-e._queueTotalSize}function ra(e,t,r){try{Ut(e,t,r)}catch(o){Le(e,o);return}const n=e._controlledWritableStream;if(!$(n)&&n._state==="writable"){const o=nr(e);tr(n,o)}lt(e)}function lt(e){const t=e._controlledWritableStream;if(!e._started){return}if(t._inFlightWriteRequest!==void 0){return}const r=t._state;if(r==="erroring"){er(t);return}if(e._queue.length===0){return}const n=po(e);if(n===bn){na(e)}else{oa(e,n)}}function Le(e,t){if(e._controlledWritableStream._state==="writable"){yn(e,t)}}function na(e){const t=e._controlledWritableStream;Ho(t);Qt(e);const r=e._closeAlgorithm();st(e);v(r,()=>{Uo(t);return null},n=>{Yo(t,n);return null})}function oa(e,t){const r=e._controlledWritableStream;Go(r);const n=e._writeAlgorithm(t);v(n,()=>{No(r);const o=r._state;Qt(e);if(!$(r)&&o==="writable"){const a=nr(e);tr(r,a)}lt(e);return null},o=>{if(r._state==="writable"){st(e)}Qo(r,o);return null})}function nr(e){const t=pn(e);return t<=0}function yn(e,t){const r=e._controlledWritableStream;st(e);Kt(r,t)}function ut(e){return new TypeError(`WritableStream.prototype.${e} can only be used on a WritableStream`)}function or(e){return new TypeError(`WritableStreamDefaultController.prototype.${e} can only be used on a WritableStreamDefaultController`)}function ye(e){return new TypeError(`WritableStreamDefaultWriter.prototype.${e} can only be used on a WritableStreamDefaultWriter`)}function $e(e){return new TypeError("Cannot "+e+" a stream using a released writer")}function ft(e){e._closedPromise=P((t,r)=>{e._closedPromise_resolve=t;e._closedPromise_reject=r;e._closedPromiseState="pending"})}function _n(e,t){ft(e);ar(e,t)}function aa(e){ft(e);Sn(e)}function ar(e,t){if(e._closedPromise_reject===void 0){return}Ce(e._closedPromise);e._closedPromise_reject(t);e._closedPromise_resolve=void 0;e._closedPromise_reject=void 0;e._closedPromiseState="rejected"}function ia(e,t){_n(e,t)}function Sn(e){if(e._closedPromise_resolve===void 0){return}e._closedPromise_resolve(void 0);e._closedPromise_resolve=void 0;e._closedPromise_reject=void 0;e._closedPromiseState="resolved"}function dt(e){e._readyPromise=P((t,r)=>{e._readyPromise_resolve=t;e._readyPromise_reject=r});e._readyPromiseState="pending"}function ir(e,t){dt(e);Rn(e,t)}function gn(e){dt(e);sr(e)}function Rn(e,t){if(e._readyPromise_reject===void 0){return}Ce(e._readyPromise);e._readyPromise_reject(t);e._readyPromise_resolve=void 0;e._readyPromise_reject=void 0;e._readyPromiseState="rejected"}function sa(e){dt(e)}function la(e,t){ir(e,t)}function sr(e){if(e._readyPromise_resolve===void 0){return}e._readyPromise_resolve(void 0);e._readyPromise_resolve=void 0;e._readyPromise_reject=void 0;e._readyPromiseState="fulfilled"}function ua(){if(typeof globalThis!=="undefined"){return globalThis}else if(typeof self!=="undefined"){return self}else if(typeof global!=="undefined"){return global}return void 0}const lr=ua();function fa(e){if(!(typeof e==="function"||typeof e==="object")){return false}if(e.name!=="DOMException"){return false}try{new e;return true}catch(t){return false}}function da(){const e=lr===null||lr===void 0?void 0:lr.DOMException;return fa(e)?e:void 0}function ca(){const e=function t(r,n){this.message=r||"";this.name=n||"Error";if(Error.captureStackTrace){Error.captureStackTrace(this,this.constructor)}};d(e,"DOMException");e.prototype=Object.create(Error.prototype);Object.defineProperty(e.prototype,"constructor",{value:e,writable:true,configurable:true});return e}const ha=da()||ca();function wn(e,t,r,n,o,a){const i=Te(e);const u=sn(t);e._disturbed=true;let p=false;let h=S(void 0);return P((y,_)=>{let C;if(a!==void 0){C=()=>{const b=a.reason!==void 0?a.reason:new ha("Aborted","AbortError");const g=[];if(!n){g.push(()=>{if(t._state==="writable"){return at(t,b)}return S(void 0)})}if(!o){g.push(()=>{if(e._state==="readable"){return j(e,b)}return S(void 0)})}A(()=>Promise.all(g.map(T=>T())),true,b)};if(a.aborted){C();return}a.addEventListener("abort",C)}function D(){return P((b,g)=>{function T(B){if(B){b()}else{W(ke(),T,g)}}T(false)})}function ke(){if(p){return S(true)}return W(u._readyPromise,()=>{return P((b,g)=>{ze(i,{_chunkSteps:T=>{h=W(hn(u,T),void 0,s);b(false)},_closeSteps:()=>b(true),_errorSteps:g})})})}Z(e,i._closedPromise,b=>{if(!n){A(()=>at(t,b),true,b)}else{z(true,b)}return null});Z(t,u._closedPromise,b=>{if(!o){A(()=>j(e,b),true,b)}else{z(true,b)}return null});q(e,i._closedPromise,()=>{if(!r){A(()=>Zo(u))}else{z()}return null});if($(t)||t._state==="closed"){const b=new TypeError("the destination writable stream closed before all data could be piped to it");if(!o){A(()=>j(e,b),true,b)}else{z(true,b)}}Ce(D());function le(){const b=h;return W(h,()=>b!==h?le():void 0)}function Z(b,g,T){if(b._state==="errored"){T(b._storedError)}else{N(g,T)}}function q(b,g,T){if(b._state==="closed"){T()}else{M(g,T)}}function A(b,g,T){if(p){return}p=true;if(t._state==="writable"&&!$(t)){M(le(),B)}else{B()}function B(){v(b(),()=>X(g,T),ge=>X(true,ge));return null}}function z(b,g){if(p){return}p=true;if(t._state==="writable"&&!$(t)){M(le(),()=>X(b,g))}else{X(b,g)}}function X(b,g){cn(u);U(i);if(a!==void 0){a.removeEventListener("abort",C)}if(b){_(g)}else{y(void 0)}return null}})}class x{constructor(){throw new TypeError("Illegal constructor")}get desiredSize(){if(!ct(this)){throw bt("desiredSize")}return ur(this)}close(){if(!ct(this)){throw bt("close")}if(!We(this)){throw new TypeError("The stream is not in a state that permits close")}_e(this)}enqueue(t=void 0){if(!ct(this)){throw bt("enqueue")}if(!We(this)){throw new TypeError("The stream is not in a state that permits enqueue")}return Ae(this,t)}error(t=void 0){if(!ct(this)){throw bt("error")}I(this,t)}[qt](t){re(this);const r=this._cancelAlgorithm(t);ht(this);return r}[At](t){const r=this._controlledReadableStream;if(this._queue.length>0){const n=Qt(this);if(this._closeRequested&&this._queue.length===0){ht(this);Ue(r)}else{Ne(this)}t._chunkSteps(n)}else{Wr(r,t);Ne(this)}}[Wt](){}}Object.defineProperties(x.prototype,{close:{enumerable:true},enqueue:{enumerable:true},error:{enumerable:true},desiredSize:{enumerable:true}});d(x.prototype.close,"close");d(x.prototype.enqueue,"enqueue");d(x.prototype.error,"error");if(typeof Symbol.toStringTag==="symbol"){Object.defineProperty(x.prototype,Symbol.toStringTag,{value:"ReadableStreamDefaultController",configurable:true})}function ct(e){if(!l(e)){return false}if(!Object.prototype.hasOwnProperty.call(e,"_controlledReadableStream")){return false}return e instanceof x}function Ne(e){const t=Cn(e);if(!t){return}if(e._pulling){e._pullAgain=true;return}e._pulling=true;const r=e._pullAlgorithm();v(r,()=>{e._pulling=false;if(e._pullAgain){e._pullAgain=false;Ne(e)}return null},n=>{I(e,n);return null})}function Cn(e){const t=e._controlledReadableStream;if(!We(e)){return false}if(!e._started){return false}if(ie(t)&&Ge(t)>0){return true}const r=ur(e);if(r>0){return true}return false}function ht(e){e._pullAlgorithm=void 0;e._cancelAlgorithm=void 0;e._strategySizeAlgorithm=void 0}function _e(e){if(!We(e)){return}const t=e._controlledReadableStream;e._closeRequested=true;if(e._queue.length===0){ht(e);Ue(t)}}function Ae(e,t){if(!We(e)){return}const r=e._controlledReadableStream;if(ie(r)&&Ge(r)>0){Dt(r,t,false)}else{let n;try{n=e._strategySizeAlgorithm(t)}catch(o){I(e,o);throw o}try{Ut(e,t,n)}catch(o){I(e,o);throw o}}Ne(e)}function I(e,t){const r=e._controlledReadableStream;if(r._state!=="readable"){return}re(e);ht(e);En(r,t)}function ur(e){const t=e._controlledReadableStream._state;if(t==="errored"){return null}if(t==="closed"){return 0}return e._strategyHWM-e._queueTotalSize}function ba(e){if(Cn(e)){return false}return true}function We(e){const t=e._controlledReadableStream._state;if(!e._closeRequested&&t==="readable"){return true}return false}function Tn(e,t,r,n,o,a,i){t._controlledReadableStream=e;t._queue=void 0;t._queueTotalSize=void 0;re(t);t._started=false;t._closeRequested=false;t._pullAgain=false;t._pulling=false;t._strategySizeAlgorithm=i;t._strategyHWM=a;t._pullAlgorithm=n;t._cancelAlgorithm=o;e._readableStreamController=t;const u=r();v(S(u),()=>{t._started=true;Ne(t);return null},p=>{I(t,p);return null})}function ma(e,t,r,n){const o=Object.create(x.prototype);let a;let i;let u;if(t.start!==void 0){a=()=>t.start(o)}else{a=()=>void 0}if(t.pull!==void 0){i=()=>t.pull(o)}else{i=()=>S(void 0)}if(t.cancel!==void 0){u=p=>t.cancel(p)}else{u=()=>S(void 0)}Tn(e,o,a,i,u,r,n)}function bt(e){return new TypeError(`ReadableStreamDefaultController.prototype.${e} can only be used on a ReadableStreamDefaultController`)}function pa(e,t){if(he(e._readableStreamController)){return _a(e)}return ya(e)}function ya(e,t){const r=Te(e);let n=false;let o=false;let a=false;let i=false;let u;let p;let h;let y;let _;const C=P(q=>{_=q});function D(){if(n){o=true;return S(void 0)}n=true;const q={_chunkSteps:A=>{fe(()=>{o=false;const z=A;const X=A;if(!a){Ae(h._readableStreamController,z)}if(!i){Ae(y._readableStreamController,X)}n=false;if(o){D()}})},_closeSteps:()=>{n=false;if(!a){_e(h._readableStreamController)}if(!i){_e(y._readableStreamController)}if(!a||!i){_(void 0)}},_errorSteps:()=>{n=false}};ze(r,q);return S(void 0)}function ke(q){a=true;u=q;if(i){const A=Ie([u,p]);const z=j(e,A);_(z)}return C}function le(q){i=true;p=q;if(a){const A=Ie([u,p]);const z=j(e,A);_(z)}return C}function Z(){}h=Qe(Z,D,ke);y=Qe(Z,D,le);N(r._closedPromise,q=>{I(h._readableStreamController,q);I(y._readableStreamController,q);if(!a||!i){_(void 0)}return null});return[h,y]}function _a(e){let t=Te(e);let r=false;let n=false;let o=false;let a=false;let i=false;let u;let p;let h;let y;let _;const C=P(b=>{_=b});function D(b){N(b._closedPromise,g=>{if(b!==t){return null}F(h._readableStreamController,g);F(y._readableStreamController,g);if(!a||!i){_(void 0)}return null})}function ke(){if(me(t)){U(t);t=Te(e);D(t)}const b={_chunkSteps:g=>{fe(()=>{n=false;o=false;const T=g;let B=g;if(!a&&!i){try{B=$r(g)}catch(ge){F(h._readableStreamController,ge);F(y._readableStreamController,ge);_(j(e,ge));return}}if(!a){Ke(h._readableStreamController,T)}if(!i){Ke(y._readableStreamController,B)}r=false;if(n){Z()}else if(o){q()}})},_closeSteps:()=>{r=false;if(!a){je(h._readableStreamController)}if(!i){je(y._readableStreamController)}if(h._readableStreamController._pendingPullIntos.length>0){et(h._readableStreamController,0)}if(y._readableStreamController._pendingPullIntos.length>0){et(y._readableStreamController,0)}if(!a||!i){_(void 0)}},_errorSteps:()=>{r=false}};ze(t,b)}function le(b,g){if(ee(t)){U(t);t=en(e);D(t)}const T=g?y:h;const B=g?h:y;const ge={_chunkSteps:Oe=>{fe(()=>{n=false;o=false;const Fe=g?i:a;const Ye=g?a:i;if(!Ye){let Ln;try{Ln=$r(Oe)}catch(br){F(T._readableStreamController,br);F(B._readableStreamController,br);_(j(e,br));return}if(!Fe){tt(T._readableStreamController,Oe)}Ke(B._readableStreamController,Ln)}else if(!Fe){tt(T._readableStreamController,Oe)}r=false;if(n){Z()}else if(o){q()}})},_closeSteps:Oe=>{r=false;const Fe=g?i:a;const Ye=g?a:i;if(!Fe){je(T._readableStreamController)}if(!Ye){je(B._readableStreamController)}if(Oe!==void 0){if(!Fe){tt(T._readableStreamController,Oe)}if(!Ye&&B._readableStreamController._pendingPullIntos.length>0){et(B._readableStreamController,0)}}if(!Fe||!Ye){_(void 0)}},_errorSteps:()=>{r=false}};nn(t,b,1,ge)}function Z(){if(r){n=true;return S(void 0)}r=true;const b=xt(h._readableStreamController);if(b===null){ke()}else{le(b._view,false)}return S(void 0)}function q(){if(r){o=true;return S(void 0)}r=true;const b=xt(y._readableStreamController);if(b===null){ke()}else{le(b._view,true)}return S(void 0)}function A(b){a=true;u=b;if(i){const g=Ie([u,p]);const T=j(e,g);_(T)}return C}function z(b){i=true;p=b;if(a){const g=Ie([u,p]);const T=j(e,g);_(T)}return C}function X(){return}h=vn(X,Z,A);y=vn(X,q,z);D(t);return[h,y]}function Sa(e){return l(e)&&typeof e.getReader!=="undefined"}function ga(e){if(Sa(e)){return wa(e.getReader())}return Ra(e)}function Ra(e){let t;const r=Lr(e,"async");const n=s;function o(){let i;try{i=co(r)}catch(p){return c(p)}const u=S(i);return Q(u,p=>{if(!l(p)){throw new TypeError("The promise returned by the iterator.next() method must fulfill with an object")}const h=ho(p);if(h){_e(t._readableStreamController)}else{const y=bo(p);Ae(t._readableStreamController,y)}})}function a(i){const u=r.iterator;let p;try{p=Ze(u,"return")}catch(_){return c(_)}if(p===void 0){return S(void 0)}let h;try{h=de(p,u,[i])}catch(_){return c(_)}const y=S(h);return Q(y,_=>{if(!l(_)){throw new TypeError("The promise returned by the iterator.return() method must fulfill with an object")}return void 0})}t=Qe(n,o,a,0);return t}function wa(e){let t;const r=s;function n(){let a;try{a=e.read()}catch(i){return c(i)}return Q(a,i=>{if(!l(i)){throw new TypeError("The promise returned by the reader.read() method must fulfill with an object")}if(i.done){_e(t._readableStreamController)}else{const u=i.value;Ae(t._readableStreamController,u)}})}function o(a){try{return S(e.cancel(a))}catch(i){return c(i)}}t=Qe(r,n,o,0);return t}function Ca(e,t){L(e,t);const r=e;const n=r===null||r===void 0?void 0:r.autoAllocateChunkSize;const o=r===null||r===void 0?void 0:r.cancel;const a=r===null||r===void 0?void 0:r.pull;const i=r===null||r===void 0?void 0:r.start;const u=r===null||r===void 0?void 0:r.type;return{autoAllocateChunkSize:n===void 0?void 0:It(n,`${t} has member 'autoAllocateChunkSize' that`),cancel:o===void 0?void 0:Ta(o,r,`${t} has member 'cancel' that`),pull:a===void 0?void 0:Pa(a,r,`${t} has member 'pull' that`),start:i===void 0?void 0:va(i,r,`${t} has member 'start' that`),type:u===void 0?void 0:Ea(u,`${t} has member 'type' that`)}}function Ta(e,t,r){O(e,r);return n=>J(e,t,[n])}function Pa(e,t,r){O(e,r);return n=>J(e,t,[n])}function va(e,t,r){O(e,r);return n=>de(e,t,[n])}function Ea(e,t){e=`${e}`;if(e!=="bytes"){throw new TypeError(`${t} '${e}' is not a valid enumeration value for ReadableStreamType`)}return e}function qa(e,t){L(e,t);const r=e===null||e===void 0?void 0:e.preventCancel;return{preventCancel:Boolean(r)}}function Pn(e,t){L(e,t);const r=e===null||e===void 0?void 0:e.preventAbort;const n=e===null||e===void 0?void 0:e.preventCancel;const o=e===null||e===void 0?void 0:e.preventClose;const a=e===null||e===void 0?void 0:e.signal;if(a!==void 0){Aa(a,`${t} has member 'signal' that`)}return{preventAbort:Boolean(r),preventCancel:Boolean(n),preventClose:Boolean(o),signal:a}}function Aa(e,t){if(!jo(e)){throw new TypeError(`${t} is not an AbortSignal.`)}}function Wa(e,t){L(e,t);const r=e===null||e===void 0?void 0:e.readable;Ft(r,"readable","ReadableWritablePair");jt(r,`${t} has member 'readable' that`);const n=e===null||e===void 0?void 0:e.writable;Ft(n,"writable","ReadableWritablePair");an(n,`${t} has member 'writable' that`);return{readable:r,writable:n}}class E{constructor(t={},r={}){if(t===void 0){t=null}else{qr(t,"First parameter")}const n=ot(r,"Second parameter");const o=Ca(t,"First parameter");fr(this);if(o.type==="bytes"){if(n.size!==void 0){throw new RangeError("The strategy for a byte stream cannot have a size function")}const a=Me(n,0);To(this,o,a)}else{const a=nt(n);const i=Me(n,1);ma(this,o,i,a)}}get locked(){if(!ae(this)){throw Se("locked")}return ie(this)}cancel(t=void 0){if(!ae(this)){return c(Se("cancel"))}if(ie(this)){return c(new TypeError("Cannot cancel a stream that already has a reader"))}return j(this,t)}getReader(t=void 0){if(!ae(this)){throw Se("getReader")}const r=vo(t,"First parameter");if(r.mode===void 0){return Te(this)}return en(this)}pipeThrough(t,r={}){if(!ae(this)){throw Se("pipeThrough")}Y(t,1,"pipeThrough");const n=Wa(t,"First parameter");const o=Pn(r,"Second parameter");if(ie(this)){throw new TypeError("ReadableStream.prototype.pipeThrough cannot be used on a locked ReadableStream")}if(Ee(n.writable)){throw new TypeError("ReadableStream.prototype.pipeThrough cannot be used on a locked WritableStream")}const a=wn(this,n.writable,o.preventClose,o.preventAbort,o.preventCancel,o.signal);Ce(a);return n.readable}pipeTo(t,r={}){if(!ae(this)){return c(Se("pipeTo"))}if(t===void 0){return c(`Parameter 1 is required in 'pipeTo'.`)}if(!ve(t)){return c(new TypeError(`ReadableStream.prototype.pipeTo's first argument must be a WritableStream`))}let n;try{n=Pn(r,"Second parameter")}catch(o){return c(o)}if(ie(this)){return c(new TypeError("ReadableStream.prototype.pipeTo cannot be used on a locked ReadableStream"))}if(Ee(t)){return c(new TypeError("ReadableStream.prototype.pipeTo cannot be used on a locked WritableStream"))}return wn(this,t,n.preventClose,n.preventAbort,n.preventCancel,n.signal)}tee(){if(!ae(this)){throw Se("tee")}const t=pa(this);return Ie(t)}values(t=void 0){if(!ae(this)){throw Se("values")}const r=qa(t,"First parameter");return uo(this,r.preventCancel)}[Nt](t){return this.values(t)}static from(t){return ga(t)}}Object.defineProperties(E,{from:{enumerable:true}});Object.defineProperties(E.prototype,{cancel:{enumerable:true},getReader:{enumerable:true},pipeThrough:{enumerable:true},pipeTo:{enumerable:true},tee:{enumerable:true},values:{enumerable:true},locked:{enumerable:true}});d(E.from,"from");d(E.prototype.cancel,"cancel");d(E.prototype.getReader,"getReader");d(E.prototype.pipeThrough,"pipeThrough");d(E.prototype.pipeTo,"pipeTo");d(E.prototype.tee,"tee");d(E.prototype.values,"values");if(typeof Symbol.toStringTag==="symbol"){Object.defineProperty(E.prototype,Symbol.toStringTag,{value:"ReadableStream",configurable:true})}Object.defineProperty(E.prototype,Nt,{value:E.prototype.values,writable:true,configurable:true});function Qe(e,t,r,n=1,o=()=>1){const a=Object.create(E.prototype);fr(a);const i=Object.create(x.prototype);Tn(a,i,e,t,r,n,o);return a}function vn(e,t,r){const n=Object.create(E.prototype);fr(n);const o=Object.create(H.prototype);Kr(n,o,e,t,r,0,void 0);return n}function fr(e){e._state="readable";e._reader=void 0;e._storedError=void 0;e._disturbed=false}function ae(e){if(!l(e)){return false}if(!Object.prototype.hasOwnProperty.call(e,"_readableStreamController")){return false}return e instanceof E}function ie(e){if(e._reader===void 0){return false}return true}function j(e,t){e._disturbed=true;if(e._state==="closed"){return S(void 0)}if(e._state==="errored"){return c(e._storedError)}Ue(e);const r=e._reader;if(r!==void 0&&me(r)){const o=r._readIntoRequests;r._readIntoRequests=new k;o.forEach(a=>{a._closeSteps(void 0)})}const n=e._readableStreamController[qt](t);return Q(n,s)}function Ue(e){e._state="closed";const t=e._reader;if(t===void 0){return}vr(t);if(ee(t)){const r=t._readRequests;t._readRequests=new k;r.forEach(n=>{n._closeSteps()})}}function En(e,t){e._state="errored";e._storedError=t;const r=e._reader;if(r===void 0){return}Ot(r,t);if(ee(r)){kr(r,t)}else{on(r,t)}}function Se(e){return new TypeError(`ReadableStream.prototype.${e} can only be used on a ReadableStream`)}function qn(e,t){L(e,t);const r=e===null||e===void 0?void 0:e.highWaterMark;Ft(r,"highWaterMark","QueuingStrategyInit");return{highWaterMark:zt(r)}}const An=e=>{return e.byteLength};d(An,"size");class mt{constructor(t){Y(t,1,"ByteLengthQueuingStrategy");t=qn(t,"First parameter");this._byteLengthQueuingStrategyHighWaterMark=t.highWaterMark}get highWaterMark(){if(!Bn(this)){throw Wn("highWaterMark")}return this._byteLengthQueuingStrategyHighWaterMark}get size(){if(!Bn(this)){throw Wn("size")}return An}}Object.defineProperties(mt.prototype,{highWaterMark:{enumerable:true},size:{enumerable:true}});if(typeof Symbol.toStringTag==="symbol"){Object.defineProperty(mt.prototype,Symbol.toStringTag,{value:"ByteLengthQueuingStrategy",configurable:true})}function Wn(e){return new TypeError(`ByteLengthQueuingStrategy.prototype.${e} can only be used on a ByteLengthQueuingStrategy`)}function Bn(e){if(!l(e)){return false}if(!Object.prototype.hasOwnProperty.call(e,"_byteLengthQueuingStrategyHighWaterMark")){return false}return e instanceof mt}const kn=()=>{return 1};d(kn,"size");class pt{constructor(t){Y(t,1,"CountQueuingStrategy");t=qn(t,"First parameter");this._countQueuingStrategyHighWaterMark=t.highWaterMark}get highWaterMark(){if(!Fn(this)){throw On("highWaterMark")}return this._countQueuingStrategyHighWaterMark}get size(){if(!Fn(this)){throw On("size")}return kn}}Object.defineProperties(pt.prototype,{highWaterMark:{enumerable:true},size:{enumerable:true}});if(typeof Symbol.toStringTag==="symbol"){Object.defineProperty(pt.prototype,Symbol.toStringTag,{value:"CountQueuingStrategy",configurable:true})}function On(e){return new TypeError(`CountQueuingStrategy.prototype.${e} can only be used on a CountQueuingStrategy`)}function Fn(e){if(!l(e)){return false}if(!Object.prototype.hasOwnProperty.call(e,"_countQueuingStrategyHighWaterMark")){return false}return e instanceof pt}function Ba(e,t){L(e,t);const r=e===null||e===void 0?void 0:e.cancel;const n=e===null||e===void 0?void 0:e.flush;const o=e===null||e===void 0?void 0:e.readableType;const a=e===null||e===void 0?void 0:e.start;const i=e===null||e===void 0?void 0:e.transform;const u=e===null||e===void 0?void 0:e.writableType;return{cancel:r===void 0?void 0:za(r,e,`${t} has member 'cancel' that`),flush:n===void 0?void 0:ka(n,e,`${t} has member 'flush' that`),readableType:o,start:a===void 0?void 0:Oa(a,e,`${t} has member 'start' that`),transform:i===void 0?void 0:Fa(i,e,`${t} has member 'transform' that`),writableType:u}}function ka(e,t,r){O(e,r);return n=>J(e,t,[n])}function Oa(e,t,r){O(e,r);return n=>de(e,t,[n])}function Fa(e,t,r){O(e,r);return(n,o)=>J(e,t,[n,o])}function za(e,t,r){O(e,r);return n=>J(e,t,[n])}class yt{constructor(t={},r={},n={}){if(t===void 0){t=null}const o=ot(r,"Second parameter");const a=ot(n,"Third parameter");const i=Ba(t,"First parameter");if(i.readableType!==void 0){throw new RangeError("Invalid readableType specified")}if(i.writableType!==void 0){throw new RangeError("Invalid writableType specified")}const u=Me(a,0);const p=nt(a);const h=Me(o,1);const y=nt(o);let _;const C=P(D=>{_=D});Ia(this,C,h,y,u,p);Da(this,i);if(i.start!==void 0){_(i.start(this._transformStreamController))}else{_(void 0)}}get readable(){if(!zn(this)){throw Mn("readable")}return this._readable}get writable(){if(!zn(this)){throw Mn("writable")}return this._writable}}Object.defineProperties(yt.prototype,{readable:{enumerable:true},writable:{enumerable:true}});if(typeof Symbol.toStringTag==="symbol"){Object.defineProperty(yt.prototype,Symbol.toStringTag,{value:"TransformStream",configurable:true})}function Ia(e,t,r,n,o,a){function i(){return t}function u(C){return $a(e,C)}function p(C){return Na(e,C)}function h(){return Qa(e)}e._writable=Lo(i,u,h,p,r,n);function y(){return Ua(e)}function _(C){return Ya(e,C)}e._readable=Qe(i,y,_,o,a);e._backpressure=void 0;e._backpressureChangePromise=void 0;e._backpressureChangePromise_resolve=void 0;_t(e,true);e._transformStreamController=void 0}function zn(e){if(!l(e)){return false}if(!Object.prototype.hasOwnProperty.call(e,"_transformStreamController")){return false}return e instanceof yt}function In(e,t){I(e._readable._readableStreamController,t);dr(e,t)}function dr(e,t){gt(e._transformStreamController);Le(e._writable._writableStreamController,t);cr(e)}function cr(e){if(e._backpressure){_t(e,false)}}function _t(e,t){if(e._backpressureChangePromise!==void 0){e._backpressureChangePromise_resolve()}e._backpressureChangePromise=P(r=>{e._backpressureChangePromise_resolve=r});e._backpressure=t}class se{constructor(){throw new TypeError("Illegal constructor")}get desiredSize(){if(!St(this)){throw Rt("desiredSize")}const t=this._controlledTransformStream._readable._readableStreamController;return ur(t)}enqueue(t=void 0){if(!St(this)){throw Rt("enqueue")}jn(this,t)}error(t=void 0){if(!St(this)){throw Rt("error")}Ma(this,t)}terminate(){if(!St(this)){throw Rt("terminate")}La(this)}}Object.defineProperties(se.prototype,{enqueue:{enumerable:true},error:{enumerable:true},terminate:{enumerable:true},desiredSize:{enumerable:true}});d(se.prototype.enqueue,"enqueue");d(se.prototype.error,"error");d(se.prototype.terminate,"terminate");if(typeof Symbol.toStringTag==="symbol"){Object.defineProperty(se.prototype,Symbol.toStringTag,{value:"TransformStreamDefaultController",configurable:true})}function St(e){if(!l(e)){return false}if(!Object.prototype.hasOwnProperty.call(e,"_controlledTransformStream")){return false}return e instanceof se}function ja(e,t,r,n,o){t._controlledTransformStream=e;e._transformStreamController=t;t._transformAlgorithm=r;t._flushAlgorithm=n;t._cancelAlgorithm=o;t._finishPromise=void 0;t._finishPromise_resolve=void 0;t._finishPromise_reject=void 0}function Da(e,t){const r=Object.create(se.prototype);let n;let o;let a;if(t.transform!==void 0){n=i=>t.transform(i,r)}else{n=i=>{try{jn(r,i);return S(void 0)}catch(u){return c(u)}}}if(t.flush!==void 0){o=()=>t.flush(r)}else{o=()=>S(void 0)}if(t.cancel!==void 0){a=i=>t.cancel(i)}else{a=()=>S(void 0)}ja(e,r,n,o,a)}function gt(e){e._transformAlgorithm=void 0;e._flushAlgorithm=void 0;e._cancelAlgorithm=void 0}function jn(e,t){const r=e._controlledTransformStream;const n=r._readable._readableStreamController;if(!We(n)){throw new TypeError("Readable side is not in a state that permits enqueue")}try{Ae(n,t)}catch(a){dr(r,a);throw r._readable._storedError}const o=ba(n);if(o!==r._backpressure){_t(r,true)}}function Ma(e,t){In(e._controlledTransformStream,t)}function Dn(e,t){const r=e._transformAlgorithm(t);return Q(r,void 0,n=>{In(e._controlledTransformStream,n);throw n})}function La(e){const t=e._controlledTransformStream;const r=t._readable._readableStreamController;_e(r);const n=new TypeError("TransformStream terminated");dr(t,n)}function $a(e,t){const r=e._transformStreamController;if(e._backpressure){const n=e._backpressureChangePromise;return Q(n,()=>{const o=e._writable;const a=o._state;if(a==="erroring"){throw o._storedError}return Dn(r,t)})}return Dn(r,t)}function Na(e,t){const r=e._transformStreamController;if(r._finishPromise!==void 0){return r._finishPromise}const n=e._readable;r._finishPromise=P((a,i)=>{r._finishPromise_resolve=a;r._finishPromise_reject=i});const o=r._cancelAlgorithm(t);gt(r);v(o,()=>{if(n._state==="errored"){Be(r,n._storedError)}else{I(n._readableStreamController,t);hr(r)}return null},a=>{I(n._readableStreamController,a);Be(r,a);return null});return r._finishPromise}function Qa(e){const t=e._transformStreamController;if(t._finishPromise!==void 0){return t._finishPromise}const r=e._readable;t._finishPromise=P((o,a)=>{t._finishPromise_resolve=o;t._finishPromise_reject=a});const n=t._flushAlgorithm();gt(t);v(n,()=>{if(r._state==="errored"){Be(t,r._storedError)}else{_e(r._readableStreamController);hr(t)}return null},o=>{I(r._readableStreamController,o);Be(t,o);return null});return t._finishPromise}function Ua(e){_t(e,false);return e._backpressureChangePromise}function Ya(e,t){const r=e._transformStreamController;if(r._finishPromise!==void 0){return r._finishPromise}const n=e._writable;r._finishPromise=P((a,i)=>{r._finishPromise_resolve=a;r._finishPromise_reject=i});const o=r._cancelAlgorithm(t);gt(r);v(o,()=>{if(n._state==="errored"){Be(r,n._storedError)}else{Le(n._writableStreamController,t);cr(e);hr(r)}return null},a=>{Le(n._writableStreamController,a);cr(e);Be(r,a);return null});return r._finishPromise}function Rt(e){return new TypeError(`TransformStreamDefaultController.prototype.${e} can only be used on a TransformStreamDefaultController`)}function hr(e){if(e._finishPromise_resolve===void 0){return}e._finishPromise_resolve();e._finishPromise_resolve=void 0;e._finishPromise_reject=void 0}function Be(e,t){if(e._finishPromise_reject===void 0){return}Ce(e._finishPromise);e._finishPromise_reject(t);e._finishPromise_resolve=void 0;e._finishPromise_reject=void 0}function Mn(e){return new TypeError(`TransformStream.prototype.${e} can only be used on a TransformStream`)}f.ByteLengthQueuingStrategy=mt;f.CountQueuingStrategy=pt;f.ReadableByteStreamController=H;f.ReadableStream=E;f.ReadableStreamBYOBReader=ne;f.ReadableStreamBYOBRequest=ce;f.ReadableStreamDefaultController=x;f.ReadableStreamDefaultReader=K;f.TransformStream=yt;f.TransformStreamDefaultController=se;f.WritableStream=oe;f.WritableStreamDefaultController=qe;f.WritableStreamDefaultWriter=G}))});var Un=mr(()=>{var Va=65536;if(!globalThis.ReadableStream){try{const f=wt("node:process");const{emitWarning:s}=f;try{f.emitWarning=()=>{};Object.assign(globalThis,wt("node:stream/web"));f.emitWarning=s}catch(l){f.emitWarning=s;throw l}}catch(f){Object.assign(globalThis,Qn())}}try{const{Blob:f}=wt("buffer");if(f&&!f.prototype.stream){f.prototype.stream=function s(l){let m=0;const d=this;return new ReadableStream({type:"bytes",async pull(R){const w=d.slice(m,Math.min(d.size,m+Va));const ue=await w.arrayBuffer();m+=ue.byteLength;R.enqueue(new Uint8Array(ue));if(m===d.size){R.close()}}})}}}catch(f){}});async function*pr(f,s=true){for(const l of f){if("stream"in l){yield*l.stream()}else if(ArrayBuffer.isView(l)){if(s){let m=l.byteOffset;const d=l.byteOffset+l.byteLength;while(m!==d){const R=Math.min(d-m,Yn);const w=l.buffer.slice(m,m+R);m+=w.byteLength;yield new Uint8Array(w)}}else{yield l}}else{let m=0,d=l;while(m!==d.size){const R=d.slice(m,Math.min(d.size,m+Yn));const w=await R.arrayBuffer();m+=w.byteLength;yield new Uint8Array(w)}}}}var ii,Yn,Vn,Ha,Re;var Pt=Ct(()=>{ii=$n(Un(),1);Yn=65536;Vn=class yr{#e=[];#t="";#r=0;#n="transparent";constructor(s=[],l={}){if(typeof s!=="object"||s===null){throw new TypeError("Failed to construct 'Blob': The provided value cannot be converted to a sequence.")}if(typeof s[Symbol.iterator]!=="function"){throw new TypeError("Failed to construct 'Blob': The object must have a callable @@iterator property.")}if(typeof l!=="object"&&typeof l!=="function"){throw new TypeError("Failed to construct 'Blob': parameter 2 cannot convert to dictionary.")}if(l===null)l={};const m=new TextEncoder;for(const R of s){let w;if(ArrayBuffer.isView(R)){w=new Uint8Array(R.buffer.slice(R.byteOffset,R.byteOffset+R.byteLength))}else if(R instanceof ArrayBuffer){w=new Uint8Array(R.slice(0))}else if(R instanceof yr){w=R}else{w=m.encode(`${R}`)}this.#r+=ArrayBuffer.isView(w)?w.byteLength:w.size;this.#e.push(w)}this.#n=`${l.endings===void 0?"transparent":l.endings}`;const d=l.type===void 0?"":String(l.type);this.#t=/^[\x20-\x7E]*$/.test(d)?d:""}get size(){return this.#r}get type(){return this.#t}async text(){const s=new TextDecoder;let l="";for await(const m of pr(this.#e,false)){l+=s.decode(m,{stream:true})}l+=s.decode();return l}async arrayBuffer(){const s=new Uint8Array(this.size);let l=0;for await(const m of pr(this.#e,false)){s.set(m,l);l+=m.length}return s.buffer}stream(){const s=pr(this.#e,true);return new globalThis.ReadableStream({type:"bytes",async pull(l){const m=await s.next();m.done?l.close():l.enqueue(m.value)},async cancel(){await s.return()}})}slice(s=0,l=this.size,m=""){const{size:d}=this;let R=s<0?Math.max(d+s,0):Math.min(s,d);let w=l<0?Math.max(d+l,0):Math.min(l,d);const ue=Math.max(w-R,0);const P=this.#e;const S=[];let c=0;for(const v of P){if(c>=ue){break}const M=ArrayBuffer.isView(v)?v.byteLength:v.size;if(R&&M<=R){R-=M;w-=M}else{let N;if(ArrayBuffer.isView(v)){N=v.subarray(R,Math.min(M,w));c+=N.byteLength}else{N=v.slice(R,Math.min(M,w));c+=N.size}w-=M;S.push(N);R=0}}const W=new yr([],{type:String(m).toLowerCase()});W.#r=ue;W.#e=S;return W}get[Symbol.toStringTag](){return"Blob"}static[Symbol.hasInstance](s){return s&&typeof s==="object"&&typeof s.constructor==="function"&&(typeof s.stream==="function"||typeof s.arrayBuffer==="function")&&/^(Blob|File)$/.test(s[Symbol.toStringTag])}};Object.defineProperties(Vn.prototype,{size:{enumerable:true},type:{enumerable:true},slice:{enumerable:true}});Ha=Vn;Re=Ha});var Ga,xa,vt;var _r=Ct(()=>{Pt();Ga=class ui extends Re{#e=0;#t="";constructor(s,l,m={}){if(arguments.length<2){throw new TypeError(`Failed to construct 'File': 2 arguments required, but only ${arguments.length} present.`)}super(s,m);if(m===null)m={};const d=m.lastModified===void 0?Date.now():Number(m.lastModified);if(!Number.isNaN(d)){this.#e=d}this.#t=String(l)}get name(){return this.#t}get lastModified(){return this.#e}get[Symbol.toStringTag](){return"File"}static[Symbol.hasInstance](s){return!!s&&s instanceof Re&&/^(File)$/.test(s[Symbol.toStringTag])}};xa=Ga;vt=xa});function mi(f,s=Re){var l=`${Hn()}${Hn()}`.replace(/\./g,"").slice(-28).padStart(32,"-"),m=[],d=`--${l}\r
|
|
3
|
+
Content-Disposition: form-data; name="`;f.forEach((R,w)=>typeof R=="string"?m.push(d+Sr(w)+`"\r
|
|
4
|
+
\r
|
|
5
|
+
${R.replace(/\r(?!\n)|(?<!\r)\n/g,"\r\n")}\r
|
|
6
|
+
`):m.push(d+Sr(w)+`"; filename="${Sr(R.name,1)}"\r
|
|
7
|
+
Content-Type: ${R.type||"application/octet-stream"}\r
|
|
8
|
+
\r
|
|
9
|
+
`,R,"\r\n"));m.push(`--${l}--`);return new s(m,{type:"multipart/form-data; boundary="+l})}var Ve,Za,Xa,Hn,Ja,Gn,Sr,we,hi;var Ka=Ct(()=>{Pt();_r();({toStringTag:Ve,iterator:Za,hasInstance:Xa}=Symbol);Hn=Math.random;Ja="append,set,get,getAll,delete,keys,values,entries,forEach,constructor".split(",");Gn=(f,s,l)=>(f+="",/^(Blob|File)$/.test(s&&s[Ve])?[(l=l!==void 0?l+"":s[Ve]=="File"?s.name:"blob",f),s.name!==l||s[Ve]=="blob"?new vt([s],l,s):s]:[f,s+""]);Sr=(f,s)=>(s?f:f.replace(/\r?\n|\r/g,"\r\n")).replace(/\n/g,"%0A").replace(/\r/g,"%0D").replace(/"/g,"%22");we=(f,s,l)=>{if(s.length<l){throw new TypeError(`Failed to execute '${f}' on 'FormData': ${l} arguments required, but only ${s.length} present.`)}};hi=class bi{#e=[];constructor(...s){if(s.length)throw new TypeError(`Failed to construct 'FormData': parameter 1 is not of type 'HTMLFormElement'.`)}get[Ve](){return"FormData"}[Za](){return this.entries()}static[Xa](s){return s&&typeof s==="object"&&s[Ve]==="FormData"&&!Ja.some(l=>typeof s[l]!="function")}append(...s){we("append",arguments,2);this.#e.push(Gn(...s))}delete(s){we("delete",arguments,1);s+="";this.#e=this.#e.filter(([l])=>l!==s)}get(s){we("get",arguments,1);s+="";for(var l=this.#e,m=l.length,d=0;d<m;d++)if(l[d][0]===s)return l[d][1];return null}getAll(s,l){we("getAll",arguments,1);l=[];s+="";this.#e.forEach(m=>m[0]===s&&l.push(m[1]));return l}has(s){we("has",arguments,1);s+="";return this.#e.some(l=>l[0]===s)}forEach(s,l){we("forEach",arguments,1);for(var[m,d]of this)s.call(l,d,m,this)}set(...s){we("set",arguments,2);var l=[],m=true;s=Gn(...s);this.#e.forEach(d=>{d[0]===s[0]?m&&(m=!l.push(s)):l.push(d)});m&&l.push(s);this.#e=l}*entries(){yield*this.#e}*keys(){for(var[s]of this)yield s}*values(){for(var[,s]of this)yield s}}});var Zn=mr((yi,xn)=>{if(!globalThis.DOMException){try{const{MessageChannel:f}=wt("worker_threads"),s=new f().port1,l=new ArrayBuffer;s.postMessage(l,[l,l])}catch(f){f.constructor.name==="DOMException"&&(globalThis.DOMException=f.constructor)}}xn.exports=globalThis.DOMException});import{statSync as Xn,createReadStream as ei,promises as ti}from"node:fs";import{basename as ri}from"node:path";var Jn,gr,wi,Ci,Ti,Pi,Kn,eo,Et;var ni=Ct(()=>{Jn=$n(Zn(),1);_r();Pt();({stat:gr}=ti);wi=(f,s)=>Kn(Xn(f),f,s);Ci=(f,s)=>gr(f).then(l=>Kn(l,f,s));Ti=(f,s)=>gr(f).then(l=>eo(l,f,s));Pi=(f,s)=>eo(Xn(f),f,s);Kn=(f,s,l="")=>new Re([new Et({path:s,size:f.size,lastModified:f.mtimeMs,start:0})],{type:l});eo=(f,s,l="")=>new vt([new Et({path:s,size:f.size,lastModified:f.mtimeMs,start:0})],ri(s),{type:l,lastModified:f.mtimeMs});Et=class f{#e;#t;constructor(s){this.#e=s.path;this.#t=s.start;this.size=s.size;this.lastModified=s.lastModified}slice(s,l){return new f({path:this.#e,lastModified:this.lastModified,size:l-s,start:this.#t+s})}async*stream(){const{mtimeMs:s}=await gr(this.#e);if(s>this.lastModified){throw new Jn.default("The requested file could not be read, typically due to permission problems that have occurred after a reference to a file was acquired.","NotReadableError")}yield*ei(this.#e,{start:this.#t,end:this.#t+this.size-1})}get[Symbol.toStringTag](){return"Blob"}}});export{Re as a,Pt as b,vt as c,hi as d,mi as e,Ka as f,wi as g,Ci as h,Ti as i,Pi as j,ni as k};
|
|
10
|
+
/*! Bundled license information:
|
|
11
|
+
|
|
12
|
+
web-streams-polyfill/dist/ponyfill.es2018.js:
|
|
13
|
+
(**
|
|
14
|
+
* @license
|
|
15
|
+
* web-streams-polyfill v3.3.3
|
|
16
|
+
* Copyright 2024 Mattias Buelens, Diwank Singh Tomer and other contributors.
|
|
17
|
+
* This code is released under the MIT license.
|
|
18
|
+
* SPDX-License-Identifier: MIT
|
|
19
|
+
*)
|
|
20
|
+
|
|
21
|
+
fetch-blob/index.js:
|
|
22
|
+
(*! fetch-blob. MIT License. Jimmy Wärting <https://jimmy.warting.se/opensource> *)
|
|
23
|
+
|
|
24
|
+
formdata-polyfill/esm.min.js:
|
|
25
|
+
(*! formdata-polyfill. MIT License. Jimmy Wärting <https://jimmy.warting.se/opensource> *)
|
|
26
|
+
|
|
27
|
+
node-domexception/index.js:
|
|
28
|
+
(*! node-domexception. MIT License. Jimmy Wärting <https://jimmy.warting.se/opensource> *)
|
|
29
|
+
*/
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { createRequire as __alran_cR } from "module"; import { basename as __alran_basename, dirname as __alran_dirname, join as __alran_join } from "path"; import { fileURLToPath as __alran_fileURLToPath, pathToFileURL as __alran_pathToFileURL } from "url"; const __alran_tuiCurrentModuleDir = __alran_dirname(__alran_fileURLToPath(import.meta.url)); const __alran_tuiPackageRoot = __alran_basename(__alran_tuiCurrentModuleDir) === "chunks" ? __alran_dirname(__alran_tuiCurrentModuleDir) : __alran_tuiCurrentModuleDir; const __alran_tuiPackageEntryUrl = __alran_pathToFileURL(__alran_join(__alran_tuiPackageRoot, "cli.js")).href; const require = __alran_cR(__alran_tuiPackageEntryUrl); const __dirname = __alran_tuiPackageRoot;
|
|
2
|
+
import{b as Or,c as Br,d as Lr}from"./chunk-N6W7ZL26.js";import{a as Ir,b as zt}from"./chunk-W5ZOLW7T.js";import{a as Mr}from"./chunk-3AODGLMF.js";import{d as Gt,f as Tr,h as Cr,i as $r,j as Nr,k as Fr,l as jr}from"./chunk-VLXX22YO.js";import{a as q}from"./chunk-7XYOYZX2.js";function p(n,e,t,r,s){if(r==="m")throw new TypeError("Private method is not writable");if(r==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof e==="function"?n!==e||!s:!e.has(n))throw new TypeError("Cannot write private member to an object whose class did not declare it");return r==="a"?s.call(n,t):s?s.value=t:e.set(n,t),t}function i(n,e,t,r){if(t==="a"&&!r)throw new TypeError("Private accessor was defined without a getter");if(typeof e==="function"?n!==e||!r:!e.has(n))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?r:t==="a"?r.call(n):r?r.value:e.get(n)}var Qt=function(){const{crypto:n}=globalThis;if(n?.randomUUID){Qt=n.randomUUID.bind(n);return n.randomUUID()}const e=new Uint8Array(1);const t=n?()=>n.getRandomValues(e)[0]:()=>Math.random()*255&255;return"10000000-1000-4000-8000-100000000000".replace(/[018]/g,r=>(+r^t()&15>>+r/4).toString(16))};function H(n){return typeof n==="object"&&n!==null&&("name"in n&&n.name==="AbortError"||"message"in n&&String(n.message).includes("FetchRequestCanceledException"))}var We=n=>{if(n instanceof Error)return n;if(typeof n==="object"&&n!==null){try{if(Object.prototype.toString.call(n)==="[object Error]"){const e=new Error(n.message,n.cause?{cause:n.cause}:{});if(n.stack)e.stack=n.stack;if(n.cause&&!e.cause)e.cause=n.cause;if(n.name)e.name=n.name;return e}}catch{}try{return new Error(JSON.stringify(n))}catch{}}return new Error(n)};var g=class extends Error{};var R=class n extends g{constructor(e,t,r,s,o){super(`${n.makeMessage(e,t,r)}`);this.status=e;this.headers=s;this.requestID=s?.get("request-id");this.error=t;this.type=o??null}static makeMessage(e,t,r){const s=t?.message?typeof t.message==="string"?t.message:JSON.stringify(t.message):t?JSON.stringify(t):r;if(e&&s){return`${e} ${s}`}if(e){return`${e} status code (no body)`}if(s){return s}return"(no status code or body)"}static generate(e,t,r,s){if(!e||!s){return new G({message:r,cause:We(t)})}const o=t;const a=o?.["error"]?.["type"];if(e===400){return new me(e,o,r,s,a)}if(e===401){return new ge(e,o,r,s,a)}if(e===403){return new _e(e,o,r,s,a)}if(e===404){return new be(e,o,r,s,a)}if(e===409){return new ye(e,o,r,s,a)}if(e===422){return new we(e,o,r,s,a)}if(e===429){return new xe(e,o,r,s,a)}if(e>=500){return new Se(e,o,r,s,a)}return new n(e,o,r,s,a)}};var T=class extends R{constructor({message:e}={}){super(void 0,void 0,e||"Request was aborted.",void 0)}};var G=class extends R{constructor({message:e,cause:t}){super(void 0,void 0,e||"Connection error.",void 0);if(t)this.cause=t}};var fe=class extends G{constructor({message:e}={}){super({message:e??"Request timed out."})}};var me=class extends R{};var ge=class extends R{};var _e=class extends R{};var be=class extends R{};var ye=class extends R{};var we=class extends R{};var xe=class extends R{};var Se=class extends R{};var qs=/^[a-z][a-z0-9+.-]*:/i;var qr=n=>{return qs.test(n)};var Yt=n=>(Yt=Array.isArray,Yt(n));var Zt=Yt;function gt(n){if(typeof n!=="object"){return{}}return n??{}}function er(n){if(!n)return true;for(const e in n)return false;return true}function Ur(n,e){return Object.prototype.hasOwnProperty.call(n,e)}var Hr=(n,e)=>{if(typeof e!=="number"||!Number.isInteger(e)){throw new g(`${n} must be an integer`)}if(e<0){throw new g(`${n} must be a positive integer`)}return e};var _t=n=>{try{return JSON.parse(n)}catch(e){return void 0}};var Dr=n=>new Promise(e=>setTimeout(e,n));var z="0.91.1";var Xr=()=>{return typeof window!=="undefined"&&typeof window.document!=="undefined"&&typeof navigator!=="undefined"};function Us(){if(typeof Deno!=="undefined"&&Deno.build!=null){return"deno"}if(typeof EdgeRuntime!=="undefined"){return"edge"}if(Object.prototype.toString.call(typeof globalThis.process!=="undefined"?globalThis.process:0)==="[object process]"){return"node"}return"unknown"}var Hs=()=>{const n=Us();if(n==="deno"){return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":z,"X-Stainless-OS":Jr(Deno.build.os),"X-Stainless-Arch":Wr(Deno.build.arch),"X-Stainless-Runtime":"deno","X-Stainless-Runtime-Version":typeof Deno.version==="string"?Deno.version:Deno.version?.deno??"unknown"}}if(typeof EdgeRuntime!=="undefined"){return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":z,"X-Stainless-OS":"Unknown","X-Stainless-Arch":`other:${EdgeRuntime}`,"X-Stainless-Runtime":"edge","X-Stainless-Runtime-Version":globalThis.process.version}}if(n==="node"){return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":z,"X-Stainless-OS":Jr(globalThis.process.platform??"unknown"),"X-Stainless-Arch":Wr(globalThis.process.arch??"unknown"),"X-Stainless-Runtime":"node","X-Stainless-Runtime-Version":globalThis.process.version??"unknown"}}const e=Ds();if(e){return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":z,"X-Stainless-OS":"Unknown","X-Stainless-Arch":"unknown","X-Stainless-Runtime":`browser:${e.browser}`,"X-Stainless-Runtime-Version":e.version}}return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":z,"X-Stainless-OS":"Unknown","X-Stainless-Arch":"unknown","X-Stainless-Runtime":"unknown","X-Stainless-Runtime-Version":"unknown"}};function Ds(){if(typeof navigator==="undefined"||!navigator){return null}const n=[{key:"edge",pattern:/Edge(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"ie",pattern:/MSIE(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"ie",pattern:/Trident(?:.*rv\:(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"chrome",pattern:/Chrome(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"firefox",pattern:/Firefox(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"safari",pattern:/(?:Version\W+(\d+)\.(\d+)(?:\.(\d+))?)?(?:\W+Mobile\S*)?\W+Safari/}];for(const{key:e,pattern:t}of n){const r=t.exec(navigator.userAgent);if(r){const s=r[1]||0;const o=r[2]||0;const a=r[3]||0;return{browser:e,version:`${s}.${o}.${a}`}}}return null}var Wr=n=>{if(n==="x32")return"x32";if(n==="x86_64"||n==="x64")return"x64";if(n==="arm")return"arm";if(n==="aarch64"||n==="arm64")return"arm64";if(n)return`other:${n}`;return"unknown"};var Jr=n=>{n=n.toLowerCase();if(n.includes("ios"))return"iOS";if(n==="android")return"Android";if(n==="darwin")return"MacOS";if(n==="win32")return"Windows";if(n==="freebsd")return"FreeBSD";if(n==="openbsd")return"OpenBSD";if(n==="linux")return"Linux";if(n)return`Other:${n}`;return"Unknown"};var Vr;var Kr=()=>{return Vr??(Vr=Hs())};function Gr(){if(typeof fetch!=="undefined"){return fetch}throw new Error("`fetch` is not defined as a global; Either pass `fetch` to the client, `new Anthropic({ fetch })` or polyfill the global, `globalThis.fetch = fetch`")}function tr(...n){const e=globalThis.ReadableStream;if(typeof e==="undefined"){throw new Error("`ReadableStream` is not defined as a global; You will need to polyfill it, `globalThis.ReadableStream = ReadableStream`")}return new e(...n)}function bt(n){let e=Symbol.asyncIterator in n?n[Symbol.asyncIterator]():n[Symbol.iterator]();return tr({start(){},async pull(t){const{done:r,value:s}=await e.next();if(r){t.close()}else{t.enqueue(s)}},async cancel(){await e.return?.()}})}function Je(n){if(n[Symbol.asyncIterator])return n;const e=n.getReader();return{async next(){try{const t=await e.read();if(t?.done)e.releaseLock();return t}catch(t){e.releaseLock();throw t}},async return(){const t=e.cancel();e.releaseLock();await t;return{done:true,value:void 0}},[Symbol.asyncIterator](){return this}}}async function zr(n){if(n===null||typeof n!=="object")return;if(n[Symbol.asyncIterator]){await n[Symbol.asyncIterator]().return?.();return}const e=n.getReader();const t=e.cancel();e.releaseLock();await t}var Qr=({headers:n,body:e})=>{return{bodyHeaders:{"content-type":"application/json"},body:JSON.stringify(e)}};function Yr(n){return Object.entries(n).filter(([e,t])=>typeof t!=="undefined").map(([e,t])=>{if(typeof t==="string"||typeof t==="number"||typeof t==="boolean"){return`${encodeURIComponent(e)}=${encodeURIComponent(t)}`}if(t===null){return`${encodeURIComponent(e)}=`}throw new g(`Cannot stringify type ${typeof t}; Expected string, number, boolean, or null. If you need to pass nested query parameters, you can manually encode them, e.g. { query: { 'foo[key1]': value1, 'foo[key2]': value2 } }, and please open a GitHub issue requesting better support for your use case.`)}).join("&")}function ts(n){let e=0;for(const s of n){e+=s.length}const t=new Uint8Array(e);let r=0;for(const s of n){t.set(s,r);r+=s.length}return t}var Zr;function Ve(n){let e;return(Zr??(e=new globalThis.TextEncoder,Zr=e.encode.bind(e)))(n)}var es;function rr(n){let e;return(es??(e=new globalThis.TextDecoder,es=e.decode.bind(e)))(n)}var $;var O;var D=class{constructor(){$.set(this,void 0);O.set(this,void 0);p(this,$,new Uint8Array,"f");p(this,O,null,"f")}decode(e){if(e==null){return[]}const t=e instanceof ArrayBuffer?new Uint8Array(e):typeof e==="string"?Ve(e):e;p(this,$,ts([i(this,$,"f"),t]),"f");const r=[];let s;while((s=Vs(i(this,$,"f"),i(this,O,"f")))!=null){if(s.carriage&&i(this,O,"f")==null){p(this,O,s.index,"f");continue}if(i(this,O,"f")!=null&&(s.index!==i(this,O,"f")+1||s.carriage)){r.push(rr(i(this,$,"f").subarray(0,i(this,O,"f")-1)));p(this,$,i(this,$,"f").subarray(i(this,O,"f")),"f");p(this,O,null,"f");continue}const o=i(this,O,"f")!==null?s.preceding-1:s.preceding;const a=rr(i(this,$,"f").subarray(0,o));r.push(a);p(this,$,i(this,$,"f").subarray(s.index),"f");p(this,O,null,"f")}return r}flush(){if(!i(this,$,"f").length){return[]}return this.decode("\n")}};$=new WeakMap,O=new WeakMap;D.NEWLINE_CHARS=new Set(["\n","\r"]);D.NEWLINE_REGEXP=/\r\n|[\n\r]/g;function Vs(n,e){const t=10;const r=13;for(let s=e??0;s<n.length;s++){if(n[s]===t){return{preceding:s,index:s+1,carriage:false}}if(n[s]===r){return{preceding:s,index:s+1,carriage:true}}}return null}function rs(n){const e=10;const t=13;for(let r=0;r<n.length-1;r++){if(n[r]===e&&n[r+1]===e){return r+2}if(n[r]===t&&n[r+1]===t){return r+2}if(n[r]===t&&n[r+1]===e&&r+3<n.length&&n[r+2]===t&&n[r+3]===e){return r+4}}return-1}var wt={off:0,error:200,warn:300,info:400,debug:500};var sr=(n,e,t)=>{if(!n){return void 0}if(Ur(wt,n)){return n}M(t).warn(`${e} was set to ${JSON.stringify(n)}, expected one of ${JSON.stringify(Object.keys(wt))}`);return void 0};function Xe(){}function yt(n,e,t){if(!e||wt[n]>wt[t]){return Xe}else{return e[n].bind(e)}}var Xs={error:Xe,warn:Xe,info:Xe,debug:Xe};var ss=new WeakMap;function M(n){const e=n.logger;const t=n.logLevel??"off";if(!e){return Xs}const r=ss.get(e);if(r&&r[0]===t){return r[1]}const s={error:yt("error",e,t),warn:yt("warn",e,t),info:yt("info",e,t),debug:yt("debug",e,t)};ss.set(e,[t,s]);return s}var W=n=>{if(n.options){n.options={...n.options};delete n.options["headers"]}if(n.headers){n.headers=Object.fromEntries((n.headers instanceof Headers?[...n.headers]:Object.entries(n.headers)).map(([e,t])=>[e,e.toLowerCase()==="x-api-key"||e.toLowerCase()==="authorization"||e.toLowerCase()==="cookie"||e.toLowerCase()==="set-cookie"?"***":t]))}if("retryOfRequestLogID"in n){if(n.retryOfRequestLogID){n.retryOf=n.retryOfRequestLogID}delete n.retryOfRequestLogID}return n};var Ke;var U=class n{constructor(e,t,r){this.iterator=e;Ke.set(this,void 0);this.controller=t;p(this,Ke,r,"f")}static fromSSEResponse(e,t,r){let s=false;const o=r?M(r):console;async function*a(){if(s){throw new g("Cannot iterate over a consumed stream, use `.tee()` to split the stream.")}s=true;let c=false;try{for await(const l of Ks(e,t)){if(l.event==="completion"){try{yield JSON.parse(l.data)}catch(h){o.error(`Could not parse message into JSON:`,l.data);o.error(`From chunk:`,l.raw);throw h}}if(l.event==="message_start"||l.event==="message_delta"||l.event==="message_stop"||l.event==="content_block_start"||l.event==="content_block_delta"||l.event==="content_block_stop"||l.event==="message"||l.event==="user.message"||l.event==="user.interrupt"||l.event==="user.tool_confirmation"||l.event==="user.custom_tool_result"||l.event==="agent.message"||l.event==="agent.thinking"||l.event==="agent.tool_use"||l.event==="agent.tool_result"||l.event==="agent.mcp_tool_use"||l.event==="agent.mcp_tool_result"||l.event==="agent.custom_tool_use"||l.event==="agent.thread_context_compacted"||l.event==="session.status_running"||l.event==="session.status_idle"||l.event==="session.status_rescheduled"||l.event==="session.status_terminated"||l.event==="session.error"||l.event==="session.deleted"||l.event==="span.model_request_start"||l.event==="span.model_request_end"){try{yield JSON.parse(l.data)}catch(h){o.error(`Could not parse message into JSON:`,l.data);o.error(`From chunk:`,l.raw);throw h}}if(l.event==="ping"){continue}if(l.event==="error"){const h=_t(l.data)??l.data;const f=h?.error?.type;throw new R(void 0,h,void 0,e.headers,f)}}c=true}catch(l){if(H(l))return;throw l}finally{if(!c)t.abort()}}return new n(a,t,r)}static fromReadableStream(e,t,r){let s=false;async function*o(){const c=new D;const l=Je(e);for await(const h of l){for(const f of c.decode(h)){yield f}}for(const h of c.flush()){yield h}}async function*a(){if(s){throw new g("Cannot iterate over a consumed stream, use `.tee()` to split the stream.")}s=true;let c=false;try{for await(const l of o()){if(c)continue;if(l)yield JSON.parse(l)}c=true}catch(l){if(H(l))return;throw l}finally{if(!c)t.abort()}}return new n(a,t,r)}[(Ke=new WeakMap,Symbol.asyncIterator)](){return this.iterator()}tee(){const e=[];const t=[];const r=this.iterator();const s=o=>{return{next:()=>{if(o.length===0){const a=r.next();e.push(a);t.push(a)}return o.shift()}}};return[new n(()=>s(e),this.controller,i(this,Ke,"f")),new n(()=>s(t),this.controller,i(this,Ke,"f"))]}toReadableStream(){const e=this;let t;return tr({async start(){t=e[Symbol.asyncIterator]()},async pull(r){try{const{value:s,done:o}=await t.next();if(o)return r.close();const a=Ve(JSON.stringify(s)+"\n");r.enqueue(a)}catch(s){r.error(s)}},async cancel(){await t.return?.()}})}};async function*Ks(n,e){if(!n.body){e.abort();if(typeof globalThis.navigator!=="undefined"&&globalThis.navigator.product==="ReactNative"){throw new g(`The default react-native fetch implementation does not support streaming. Please use expo/fetch: https://docs.expo.dev/versions/latest/sdk/expo/#expofetch-api`)}throw new g(`Attempted to iterate over a response with no body`)}const t=new nr;const r=new D;const s=Je(n.body);for await(const o of Gs(s)){for(const a of r.decode(o)){const c=t.decode(a);if(c)yield c}}for(const o of r.flush()){const a=t.decode(o);if(a)yield a}}async function*Gs(n){let e=new Uint8Array;for await(const t of n){if(t==null){continue}const r=t instanceof ArrayBuffer?new Uint8Array(t):typeof t==="string"?Ve(t):t;let s=new Uint8Array(e.length+r.length);s.set(e);s.set(r,e.length);e=s;let o;while((o=rs(e))!==-1){yield e.slice(0,o);e=e.slice(o)}}if(e.length>0){yield e}}var nr=class{constructor(){this.event=null;this.data=[];this.chunks=[]}decode(e){if(e.endsWith("\r")){e=e.substring(0,e.length-1)}if(!e){if(!this.event&&!this.data.length)return null;const o={event:this.event,data:this.data.join("\n"),raw:this.chunks};this.event=null;this.data=[];this.chunks=[];return o}this.chunks.push(e);if(e.startsWith(":")){return null}let[t,r,s]=zs(e,":");if(s.startsWith(" ")){s=s.substring(1)}if(t==="event"){this.event=s}else if(t==="data"){this.data.push(s)}return null}};function zs(n,e){const t=n.indexOf(e);if(t!==-1){return[n.substring(0,t),e,n.substring(t+e.length)]}return[n,"",""]}async function xt(n,e){const{response:t,requestLogID:r,retryOfRequestLogID:s,startTime:o}=e;const a=await(async()=>{if(e.options.stream){M(n).debug("response",t.status,t.url,t.headers,t.body);if(e.options.__streamClass){return e.options.__streamClass.fromSSEResponse(t,e.controller)}return U.fromSSEResponse(t,e.controller)}if(t.status===204){return null}if(e.options.__binaryResponse){return t}const c=t.headers.get("content-type");const l=c?.split(";")[0]?.trim();const h=l?.includes("application/json")||l?.endsWith("+json");if(h){const m=t.headers.get("content-length");if(m==="0"){return void 0}const x=await t.json();return or(x,t)}const f=await t.text();return f})();M(n).debug(`[${r}] response parsed`,W({retryOfRequestLogID:s,url:t.url,status:t.status,body:a,durationMs:Date.now()-o}));return a}function or(n,e){if(!n||typeof n!=="object"||Array.isArray(n)){return n}return Object.defineProperty(n,"_request_id",{value:e.headers.get("request-id"),enumerable:false})}var Ge;var se=class n extends Promise{constructor(e,t,r=xt){super(s=>{s(null)});this.responsePromise=t;this.parseResponse=r;Ge.set(this,void 0);p(this,Ge,e,"f")}_thenUnwrap(e){return new n(i(this,Ge,"f"),this.responsePromise,async(t,r)=>or(e(await this.parseResponse(t,r),r),r.response))}asResponse(){return this.responsePromise.then(e=>e.response)}async withResponse(){const[e,t]=await Promise.all([this.parse(),this.asResponse()]);return{data:e,response:t,request_id:t.headers.get("request-id")}}parse(){if(!this.parsedPromise){this.parsedPromise=this.responsePromise.then(e=>this.parseResponse(i(this,Ge,"f"),e))}return this.parsedPromise}then(e,t){return this.parse().then(e,t)}catch(e){return this.parse().catch(e)}finally(e){return this.parse().finally(e)}};Ge=new WeakMap;var St;var kt=class{constructor(e,t,r,s){St.set(this,void 0);p(this,St,e,"f");this.options=s;this.response=t;this.body=r}hasNextPage(){const e=this.getPaginatedItems();if(!e.length)return false;return this.nextPageRequestOptions()!=null}async getNextPage(){const e=this.nextPageRequestOptions();if(!e){throw new g("No next page expected; please check `.hasNextPage()` before calling `.getNextPage()`.")}return await i(this,St,"f").requestAPIList(this.constructor,e)}async*iterPages(){let e=this;yield e;while(e.hasNextPage()){e=await e.getNextPage();yield e}}async*[(St=new WeakMap,Symbol.asyncIterator)](){for await(const e of this.iterPages()){for(const t of e.getPaginatedItems()){yield t}}}};var ze=class extends se{constructor(e,t,r){super(e,t,async(s,o)=>new r(s,o.response,await xt(s,o),o.options))}async*[Symbol.asyncIterator](){const e=await this;for await(const t of e){yield t}}};var N=class extends kt{constructor(e,t,r,s){super(e,t,r,s);this.data=r.data||[];this.has_more=r.has_more||false;this.first_id=r.first_id||null;this.last_id=r.last_id||null}getPaginatedItems(){return this.data??[]}hasNextPage(){if(this.has_more===false){return false}return super.hasNextPage()}nextPageRequestOptions(){if(this.options.query?.["before_id"]){const t=this.first_id;if(!t){return null}return{...this.options,query:{...gt(this.options.query),before_id:t}}}const e=this.last_id;if(!e){return null}return{...this.options,query:{...gt(this.options.query),after_id:e}}}};var k=class extends kt{constructor(e,t,r,s){super(e,t,r,s);this.data=r.data||[];this.next_page=r.next_page||null}getPaginatedItems(){return this.data??[]}nextPageRequestOptions(){const e=this.next_page;if(!e){return null}return{...this.options,query:{...gt(this.options.query),page:e}}}};var ir=()=>{if(typeof File==="undefined"){const{process:n}=globalThis;const e=typeof n?.versions?.node==="string"&&parseInt(n.versions.node.split("."))<20;throw new Error("`File` is not defined as a global, which is required for file uploads."+(e?" Update to Node 20 LTS or newer, or set `globalThis.File` to `import('node:buffer').File`.":""))}};function ne(n,e,t){ir();return new File(n,e??"unknown_file",t)}function Qe(n,e){const t=typeof n==="object"&&n!==null&&("name"in n&&n.name&&String(n.name)||"url"in n&&n.url&&String(n.url)||"filename"in n&&n.filename&&String(n.filename)||"path"in n&&n.path&&String(n.path))||"";return e?t.split(/[\\/]/).pop()||void 0:t}var cr=n=>n!=null&&typeof n==="object"&&typeof n[Symbol.asyncIterator]==="function";var ke=async(n,e,t=true)=>{return{...n,body:await Zs(n.body,e,t)}};var ns=new WeakMap;function Ys(n){const e=typeof n==="function"?n:n.fetch;const t=ns.get(e);if(t)return t;const r=(async()=>{try{const s="Response"in e?e.Response:(await e("data:,")).constructor;const o=new FormData;if(o.toString()===await new s(o).text()){return false}return true}catch{return true}})();ns.set(e,r);return r}var Zs=async(n,e,t=true)=>{if(!await Ys(e)){throw new TypeError("The provided fetch function does not support file uploads with the current global FormData class.")}const r=new FormData;await Promise.all(Object.entries(n||{}).map(([s,o])=>ar(r,s,o,t)));return r};var en=n=>n instanceof Blob&&"name"in n;var ar=async(n,e,t,r)=>{if(t===void 0)return;if(t==null){throw new TypeError(`Received null for "${e}"; to pass null in FormData, you must use the string 'null'`)}if(typeof t==="string"||typeof t==="number"||typeof t==="boolean"){n.append(e,String(t))}else if(t instanceof Response){let s={};const o=t.headers.get("Content-Type");if(o){s={type:o}}n.append(e,ne([await t.blob()],Qe(t,r),s))}else if(cr(t)){n.append(e,ne([await new Response(bt(t)).blob()],Qe(t,r)))}else if(en(t)){n.append(e,ne([t],Qe(t,r),{type:t.type}))}else if(Array.isArray(t)){await Promise.all(t.map(s=>ar(n,e+"[]",s,r)))}else if(typeof t==="object"){await Promise.all(Object.entries(t).map(([s,o])=>ar(n,`${e}[${s}]`,o,r)))}else{throw new TypeError(`Invalid value given to form, expected a string, number, boolean, object, Array, File or Blob but got ${t} instead`)}};var os=n=>n!=null&&typeof n==="object"&&typeof n.size==="number"&&typeof n.type==="string"&&typeof n.text==="function"&&typeof n.slice==="function"&&typeof n.arrayBuffer==="function";var tn=n=>n!=null&&typeof n==="object"&&typeof n.name==="string"&&typeof n.lastModified==="number"&&os(n);var rn=n=>n!=null&&typeof n==="object"&&typeof n.url==="string"&&typeof n.blob==="function";async function vt(n,e,t){ir();n=await n;e||(e=Qe(n,true));if(tn(n)){if(n instanceof File&&e==null&&t==null){return n}return ne([await n.arrayBuffer()],e??n.name,{type:n.type,lastModified:n.lastModified,...t})}if(rn(n)){const s=await n.blob();e||(e=new URL(n.url).pathname.split(/[\\/]/).pop());return ne(await lr(s),e,t)}const r=await lr(n);if(!t?.type){const s=r.find(o=>typeof o==="object"&&"type"in o&&o.type);if(typeof s==="string"){t={...t,type:s}}}return ne(r,e,t)}async function lr(n){let e=[];if(typeof n==="string"||ArrayBuffer.isView(n)||n instanceof ArrayBuffer){e.push(n)}else if(os(n)){e.push(n instanceof Blob?n:await n.arrayBuffer())}else if(cr(n)){for await(const t of n){e.push(...await lr(t))}}else{const t=n?.constructor?.name;throw new Error(`Unexpected data type: ${typeof n}${t?`; constructor: ${t}`:""}${sn(n)}`)}return e}function sn(n){if(typeof n!=="object"||n===null)return"";const e=Object.getOwnPropertyNames(n);return`; props: [${e.map(t=>`"${t}"`).join(", ")}]`}var y=class{constructor(e){this._client=e}};var as=Symbol.for("brand.privateNullableHeaders");function*on(n){if(!n)return;if(as in n){const{values:r,nulls:s}=n;yield*r.entries();for(const o of s){yield[o,null]}return}let e=false;let t;if(n instanceof Headers){t=n.entries()}else if(Zt(n)){t=n}else{e=true;t=Object.entries(n??{})}for(let r of t){const s=r[0];if(typeof s!=="string")throw new TypeError("expected header name to be a string");const o=Zt(r[1])?r[1]:[r[1]];let a=false;for(const c of o){if(c===void 0)continue;if(e&&!a){a=true;yield[s,null]}yield[s,c]}}}var u=n=>{const e=new Headers;const t=new Set;for(const r of n){const s=new Set;for(const[o,a]of on(r)){const c=o.toLowerCase();if(!s.has(c)){e.delete(o);s.add(c)}if(a===null){e.delete(o);t.add(c)}else{e.append(o,a);t.delete(c)}}}return{[as]:true,values:e,nulls:t}};function cs(n){return n.replace(/[^A-Za-z0-9\-._~!$&'()*+,;=:@]+/g,encodeURIComponent)}var is=Object.freeze(Object.create(null));var an=(n=cs)=>function e(t,...r){if(t.length===1)return t[0];let s=false;const o=[];const a=t.reduce((f,m,x)=>{if(/[?#]/.test(m)){s=true}const _=r[x];let E=(s?encodeURIComponent:n)(""+_);if(x!==r.length&&(_==null||typeof _==="object"&&_.toString===Object.getPrototypeOf(Object.getPrototypeOf(_.hasOwnProperty??is)??is)?.toString)){E=_+"";o.push({start:f.length+m.length,length:E.length,error:`Value of type ${Object.prototype.toString.call(_).slice(8,-1)} is not a valid path parameter`})}return f+m+(x===r.length?"":E)},"");const c=a.split(/[?#]/,1)[0];const l=/(?<=^|\/)(?:\.|%2e){1,2}(?=\/|$)/gi;let h;while((h=l.exec(c))!==null){o.push({start:h.index,length:h[0].length,error:`Value "${h[0]}" can't be safely passed as a path parameter`})}o.sort((f,m)=>f.start-m.start);if(o.length>0){let f=0;const m=o.reduce((x,_)=>{const E=" ".repeat(_.start-f);const b="^".repeat(_.length);f=_.start+_.length;return x+E+b},"");throw new g(`Path parameters result in path with invalid segments:
|
|
3
|
+
${o.map(x=>x.error).join("\n")}
|
|
4
|
+
${a}
|
|
5
|
+
${m}`)}return a};var d=an(cs);var ve=class extends y{create(e,t){const{betas:r,...s}=e;return this._client.post("/v1/environments?beta=true",{body:s,...t,headers:u([{"anthropic-beta":[...r??[],"managed-agents-2026-04-01"].toString()},t?.headers])})}retrieve(e,t={},r){const{betas:s}=t??{};return this._client.get(d`/v1/environments/${e}?beta=true`,{...r,headers:u([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString()},r?.headers])})}update(e,t,r){const{betas:s,...o}=t;return this._client.post(d`/v1/environments/${e}?beta=true`,{body:o,...r,headers:u([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString()},r?.headers])})}list(e={},t){const{betas:r,...s}=e??{};return this._client.getAPIList("/v1/environments?beta=true",k,{query:s,...t,headers:u([{"anthropic-beta":[...r??[],"managed-agents-2026-04-01"].toString()},t?.headers])})}delete(e,t={},r){const{betas:s}=t??{};return this._client.delete(d`/v1/environments/${e}?beta=true`,{...r,headers:u([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString()},r?.headers])})}archive(e,t={},r){const{betas:s}=t??{};return this._client.post(d`/v1/environments/${e}/archive?beta=true`,{...r,headers:u([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString()},r?.headers])})}};var Ye=Symbol("anthropic.sdk.stainlessHelper");function At(n){return typeof n==="object"&&n!==null&&Ye in n}function ur(n,e){const t=new Set;if(n){for(const r of n){if(At(r)){t.add(r[Ye])}}}if(e){for(const r of e){if(At(r)){t.add(r[Ye])}if(Array.isArray(r.content)){for(const s of r.content){if(At(s)){t.add(s[Ye])}}}}}return Array.from(t)}function Pt(n,e){const t=ur(n,e);if(t.length===0)return{};return{"x-stainless-helper":t.join(", ")}}function ls(n){if(At(n)){return{"x-stainless-helper":n[Ye]}}return{}}var Ae=class extends y{list(e={},t){const{betas:r,...s}=e??{};return this._client.getAPIList("/v1/files?beta=true",N,{query:s,...t,headers:u([{"anthropic-beta":[...r??[],"files-api-2025-04-14"].toString()},t?.headers])})}delete(e,t={},r){const{betas:s}=t??{};return this._client.delete(d`/v1/files/${e}?beta=true`,{...r,headers:u([{"anthropic-beta":[...s??[],"files-api-2025-04-14"].toString()},r?.headers])})}download(e,t={},r){const{betas:s}=t??{};return this._client.get(d`/v1/files/${e}/content?beta=true`,{...r,headers:u([{"anthropic-beta":[...s??[],"files-api-2025-04-14"].toString(),Accept:"application/binary"},r?.headers]),__binaryResponse:true})}retrieveMetadata(e,t={},r){const{betas:s}=t??{};return this._client.get(d`/v1/files/${e}?beta=true`,{...r,headers:u([{"anthropic-beta":[...s??[],"files-api-2025-04-14"].toString()},r?.headers])})}upload(e,t){const{betas:r,...s}=e;return this._client.post("/v1/files?beta=true",ke({body:s,...t,headers:u([{"anthropic-beta":[...r??[],"files-api-2025-04-14"].toString()},ls(s.file),t?.headers])},this._client))}};var Pe=class extends y{retrieve(e,t={},r){const{betas:s}=t??{};return this._client.get(d`/v1/models/${e}?beta=true`,{...r,headers:u([{...s?.toString()!=null?{"anthropic-beta":s?.toString()}:void 0},r?.headers])})}list(e={},t){const{betas:r,...s}=e??{};return this._client.getAPIList("/v1/models?beta=true",N,{query:s,...t,headers:u([{...r?.toString()!=null?{"anthropic-beta":r?.toString()}:void 0},t?.headers])})}};var Ee=class extends y{create(e,t){const{betas:r,...s}=e;return this._client.post("/v1/user_profiles?beta=true",{body:s,...t,headers:u([{"anthropic-beta":[...r??[],"user-profiles-2026-03-24"].toString()},t?.headers])})}retrieve(e,t={},r){const{betas:s}=t??{};return this._client.get(d`/v1/user_profiles/${e}?beta=true`,{...r,headers:u([{"anthropic-beta":[...s??[],"user-profiles-2026-03-24"].toString()},r?.headers])})}update(e,t,r){const{betas:s,...o}=t;return this._client.post(d`/v1/user_profiles/${e}?beta=true`,{body:o,...r,headers:u([{"anthropic-beta":[...s??[],"user-profiles-2026-03-24"].toString()},r?.headers])})}list(e={},t){const{betas:r,...s}=e??{};return this._client.getAPIList("/v1/user_profiles?beta=true",k,{query:s,...t,headers:u([{"anthropic-beta":[...r??[],"user-profiles-2026-03-24"].toString()},t?.headers])})}createEnrollmentURL(e,t={},r){const{betas:s}=t??{};return this._client.post(d`/v1/user_profiles/${e}/enrollment_url?beta=true`,{...r,headers:u([{"anthropic-beta":[...s??[],"user-profiles-2026-03-24"].toString()},r?.headers])})}};var Re=class extends y{list(e,t={},r){const{betas:s,...o}=t??{};return this._client.getAPIList(d`/v1/agents/${e}/versions?beta=true`,k,{query:o,...r,headers:u([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString()},r?.headers])})}};var oe=class extends y{constructor(){super(...arguments);this.versions=new Re(this._client)}create(e,t){const{betas:r,...s}=e;return this._client.post("/v1/agents?beta=true",{body:s,...t,headers:u([{"anthropic-beta":[...r??[],"managed-agents-2026-04-01"].toString()},t?.headers])})}retrieve(e,t={},r){const{betas:s,...o}=t??{};return this._client.get(d`/v1/agents/${e}?beta=true`,{query:o,...r,headers:u([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString()},r?.headers])})}update(e,t,r){const{betas:s,...o}=t;return this._client.post(d`/v1/agents/${e}?beta=true`,{body:o,...r,headers:u([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString()},r?.headers])})}list(e={},t){const{betas:r,...s}=e??{};return this._client.getAPIList("/v1/agents?beta=true",k,{query:s,...t,headers:u([{"anthropic-beta":[...r??[],"managed-agents-2026-04-01"].toString()},t?.headers])})}archive(e,t={},r){const{betas:s}=t??{};return this._client.post(d`/v1/agents/${e}/archive?beta=true`,{...r,headers:u([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString()},r?.headers])})}};oe.Versions=Re;var Me=class extends y{create(e,t,r){const{view:s,betas:o,...a}=t;return this._client.post(d`/v1/memory_stores/${e}/memories?beta=true`,{query:{view:s},body:a,...r,headers:u([{"anthropic-beta":[...o??[],"managed-agents-2026-04-01"].toString()},r?.headers])})}retrieve(e,t,r){const{memory_store_id:s,betas:o,...a}=t;return this._client.get(d`/v1/memory_stores/${s}/memories/${e}?beta=true`,{query:a,...r,headers:u([{"anthropic-beta":[...o??[],"managed-agents-2026-04-01"].toString()},r?.headers])})}update(e,t,r){const{memory_store_id:s,view:o,betas:a,...c}=t;return this._client.post(d`/v1/memory_stores/${s}/memories/${e}?beta=true`,{query:{view:o},body:c,...r,headers:u([{"anthropic-beta":[...a??[],"managed-agents-2026-04-01"].toString()},r?.headers])})}list(e,t={},r){const{betas:s,...o}=t??{};return this._client.getAPIList(d`/v1/memory_stores/${e}/memories?beta=true`,k,{query:o,...r,headers:u([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString()},r?.headers])})}delete(e,t,r){const{memory_store_id:s,expected_content_sha256:o,betas:a}=t;return this._client.delete(d`/v1/memory_stores/${s}/memories/${e}?beta=true`,{query:{expected_content_sha256:o},...r,headers:u([{"anthropic-beta":[...a??[],"managed-agents-2026-04-01"].toString()},r?.headers])})}};var Te=class extends y{retrieve(e,t,r){const{memory_store_id:s,betas:o,...a}=t;return this._client.get(d`/v1/memory_stores/${s}/memory_versions/${e}?beta=true`,{query:a,...r,headers:u([{"anthropic-beta":[...o??[],"managed-agents-2026-04-01"].toString()},r?.headers])})}list(e,t={},r){const{betas:s,...o}=t??{};return this._client.getAPIList(d`/v1/memory_stores/${e}/memory_versions?beta=true`,k,{query:o,...r,headers:u([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString()},r?.headers])})}redact(e,t,r){const{memory_store_id:s,betas:o}=t;return this._client.post(d`/v1/memory_stores/${s}/memory_versions/${e}/redact?beta=true`,{...r,headers:u([{"anthropic-beta":[...o??[],"managed-agents-2026-04-01"].toString()},r?.headers])})}};var Q=class extends y{constructor(){super(...arguments);this.memories=new Me(this._client);this.memoryVersions=new Te(this._client)}create(e,t){const{betas:r,...s}=e;return this._client.post("/v1/memory_stores?beta=true",{body:s,...t,headers:u([{"anthropic-beta":[...r??[],"managed-agents-2026-04-01"].toString()},t?.headers])})}retrieve(e,t={},r){const{betas:s}=t??{};return this._client.get(d`/v1/memory_stores/${e}?beta=true`,{...r,headers:u([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString()},r?.headers])})}update(e,t,r){const{betas:s,...o}=t;return this._client.post(d`/v1/memory_stores/${e}?beta=true`,{body:o,...r,headers:u([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString()},r?.headers])})}list(e={},t){const{betas:r,...s}=e??{};return this._client.getAPIList("/v1/memory_stores?beta=true",k,{query:s,...t,headers:u([{"anthropic-beta":[...r??[],"managed-agents-2026-04-01"].toString()},t?.headers])})}delete(e,t={},r){const{betas:s}=t??{};return this._client.delete(d`/v1/memory_stores/${e}?beta=true`,{...r,headers:u([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString()},r?.headers])})}archive(e,t={},r){const{betas:s}=t??{};return this._client.post(d`/v1/memory_stores/${e}/archive?beta=true`,{...r,headers:u([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString()},r?.headers])})}};Q.Memories=Me;Q.MemoryVersions=Te;var Et={"claude-opus-4-20250514":8192,"claude-opus-4-0":8192,"claude-4-opus-20250514":8192,"anthropic.claude-opus-4-20250514-v1:0":8192,"claude-opus-4@20250514":8192,"claude-opus-4-1-20250805":8192,"anthropic.claude-opus-4-1-20250805-v1:0":8192,"claude-opus-4-1@20250805":8192};function us(n){return n?.output_format??n?.output_config?.format}function hr(n,e,t){const r=us(e);if(!e||!("parse"in(r??{}))){return{...n,content:n.content.map(s=>{if(s.type==="text"){const o=Object.defineProperty({...s},"parsed_output",{value:null,enumerable:false});return Object.defineProperty(o,"parsed",{get(){t.logger.warn("The `parsed` property on `text` blocks is deprecated, please use `parsed_output` instead.");return null},enumerable:false})}return s}),parsed_output:null}}return dr(n,e,t)}function dr(n,e,t){let r=null;const s=n.content.map(o=>{if(o.type==="text"){const a=_n(e,o.text);if(r===null){r=a}const c=Object.defineProperty({...o},"parsed_output",{value:a,enumerable:false});return Object.defineProperty(c,"parsed",{get(){t.logger.warn("The `parsed` property on `text` blocks is deprecated, please use `parsed_output` instead.");return a},enumerable:false})}return o});return{...n,content:s,parsed_output:r}}function _n(n,e){const t=us(n);if(t?.type!=="json_schema"){return null}try{if("parse"in t){return t.parse(e)}return JSON.parse(e)}catch(r){throw new g(`Failed to parse structured output: ${r}`)}}var bn=n=>{let e=0;let t=[];while(e<n.length){let r=n[e];if(r==="\\"){e++;continue}if(r==="{"){t.push({type:"brace",value:"{"});e++;continue}if(r==="}"){t.push({type:"brace",value:"}"});e++;continue}if(r==="["){t.push({type:"paren",value:"["});e++;continue}if(r==="]"){t.push({type:"paren",value:"]"});e++;continue}if(r===":"){t.push({type:"separator",value:":"});e++;continue}if(r===","){t.push({type:"delimiter",value:","});e++;continue}if(r==='"'){let c="";let l=false;r=n[++e];while(r!=='"'){if(e===n.length){l=true;break}if(r==="\\"){e++;if(e===n.length){l=true;break}c+=r+n[e];r=n[++e]}else{c+=r;r=n[++e]}}r=n[++e];if(!l){t.push({type:"string",value:c})}continue}let s=/\s/;if(r&&s.test(r)){e++;continue}let o=/[0-9]/;if(r&&o.test(r)||r==="-"||r==="."){let c="";if(r==="-"){c+=r;r=n[++e]}while(r&&o.test(r)||r==="."){c+=r;r=n[++e]}t.push({type:"number",value:c});continue}let a=/[a-z]/i;if(r&&a.test(r)){let c="";while(r&&a.test(r)){if(e===n.length){break}c+=r;r=n[++e]}if(c=="true"||c=="false"||c==="null"){t.push({type:"name",value:c})}else{e++;continue}continue}e++}return t};var Ie=n=>{if(n.length===0){return n}let e=n[n.length-1];switch(e.type){case"separator":n=n.slice(0,n.length-1);return Ie(n);break;case"number":let t=e.value[e.value.length-1];if(t==="."||t==="-"){n=n.slice(0,n.length-1);return Ie(n)}case"string":let r=n[n.length-2];if(r?.type==="delimiter"){n=n.slice(0,n.length-1);return Ie(n)}else if(r?.type==="brace"&&r.value==="{"){n=n.slice(0,n.length-1);return Ie(n)}break;case"delimiter":n=n.slice(0,n.length-1);return Ie(n);break}return n};var yn=n=>{let e=[];n.map(t=>{if(t.type==="brace"){if(t.value==="{"){e.push("}")}else{e.splice(e.lastIndexOf("}"),1)}}if(t.type==="paren"){if(t.value==="["){e.push("]")}else{e.splice(e.lastIndexOf("]"),1)}}});if(e.length>0){e.reverse().map(t=>{if(t==="}"){n.push({type:"brace",value:"}"})}else if(t==="]"){n.push({type:"paren",value:"]"})}})}return n};var wn=n=>{let e="";n.map(t=>{switch(t.type){case"string":e+='"'+t.value+'"';break;default:e+=t.value;break}});return e};var Rt=n=>JSON.parse(wn(yn(Ie(bn(n)))));var F;var Y;var Ce;var Ze;var Mt;var et;var tt;var Tt;var rt;var J;var st;var It;var Ct;var ae;var $t;var Ot;var nt;var pr;var hs;var Bt;var fr;var mr;var gr;var ds;var ps="__json_buf";function fs(n){return n.type==="tool_use"||n.type==="server_tool_use"||n.type==="mcp_tool_use"}var Lt=class n{constructor(e,t){F.add(this);this.messages=[];this.receivedMessages=[];Y.set(this,void 0);Ce.set(this,null);this.controller=new AbortController;Ze.set(this,void 0);Mt.set(this,()=>{});et.set(this,()=>{});tt.set(this,void 0);Tt.set(this,()=>{});rt.set(this,()=>{});J.set(this,{});st.set(this,false);It.set(this,false);Ct.set(this,false);ae.set(this,false);$t.set(this,void 0);Ot.set(this,void 0);nt.set(this,void 0);Bt.set(this,r=>{p(this,It,true,"f");if(H(r)){r=new T}if(r instanceof T){p(this,Ct,true,"f");return this._emit("abort",r)}if(r instanceof g){return this._emit("error",r)}if(r instanceof Error){const s=new g(r.message);s.cause=r;return this._emit("error",s)}return this._emit("error",new g(String(r)))});p(this,Ze,new Promise((r,s)=>{p(this,Mt,r,"f");p(this,et,s,"f")}),"f");p(this,tt,new Promise((r,s)=>{p(this,Tt,r,"f");p(this,rt,s,"f")}),"f");i(this,Ze,"f").catch(()=>{});i(this,tt,"f").catch(()=>{});p(this,Ce,e,"f");p(this,nt,t?.logger??console,"f")}get response(){return i(this,$t,"f")}get request_id(){return i(this,Ot,"f")}async withResponse(){p(this,ae,true,"f");const e=await i(this,Ze,"f");if(!e){throw new Error("Could not resolve a `Response` object")}return{data:this,response:e,request_id:e.headers.get("request-id")}}static fromReadableStream(e){const t=new n(null);t._run(()=>t._fromReadableStream(e));return t}static createMessage(e,t,r,{logger:s}={}){const o=new n(t,{logger:s});for(const a of t.messages){o._addMessageParam(a)}p(o,Ce,{...t,stream:true},"f");o._run(()=>o._createMessage(e,{...t,stream:true},{...r,headers:{...r?.headers,"X-Stainless-Helper-Method":"stream"}}));return o}_run(e){e().then(()=>{this._emitFinal();this._emit("end")},i(this,Bt,"f"))}_addMessageParam(e){this.messages.push(e)}_addMessage(e,t=true){this.receivedMessages.push(e);if(t){this._emit("message",e)}}async _createMessage(e,t,r){const s=r?.signal;let o;if(s){if(s.aborted)this.controller.abort();o=this.controller.abort.bind(this.controller);s.addEventListener("abort",o)}try{i(this,F,"m",fr).call(this);const{response:a,data:c}=await e.create({...t,stream:true},{...r,signal:this.controller.signal}).withResponse();this._connected(a);for await(const l of c){i(this,F,"m",mr).call(this,l)}if(c.controller.signal?.aborted){throw new T}i(this,F,"m",gr).call(this)}finally{if(s&&o){s.removeEventListener("abort",o)}}}_connected(e){if(this.ended)return;p(this,$t,e,"f");p(this,Ot,e?.headers.get("request-id"),"f");i(this,Mt,"f").call(this,e);this._emit("connect")}get ended(){return i(this,st,"f")}get errored(){return i(this,It,"f")}get aborted(){return i(this,Ct,"f")}abort(){this.controller.abort()}on(e,t){const r=i(this,J,"f")[e]||(i(this,J,"f")[e]=[]);r.push({listener:t});return this}off(e,t){const r=i(this,J,"f")[e];if(!r)return this;const s=r.findIndex(o=>o.listener===t);if(s>=0)r.splice(s,1);return this}once(e,t){const r=i(this,J,"f")[e]||(i(this,J,"f")[e]=[]);r.push({listener:t,once:true});return this}emitted(e){return new Promise((t,r)=>{p(this,ae,true,"f");if(e!=="error")this.once("error",r);this.once(e,t)})}async done(){p(this,ae,true,"f");await i(this,tt,"f")}get currentMessage(){return i(this,Y,"f")}async finalMessage(){await this.done();return i(this,F,"m",pr).call(this)}async finalText(){await this.done();return i(this,F,"m",hs).call(this)}_emit(e,...t){if(i(this,st,"f"))return;if(e==="end"){p(this,st,true,"f");i(this,Tt,"f").call(this)}const r=i(this,J,"f")[e];if(r){i(this,J,"f")[e]=r.filter(s=>!s.once);r.forEach(({listener:s})=>s(...t))}if(e==="abort"){const s=t[0];if(!i(this,ae,"f")&&!r?.length){Promise.reject(s)}i(this,et,"f").call(this,s);i(this,rt,"f").call(this,s);this._emit("end");return}if(e==="error"){const s=t[0];if(!i(this,ae,"f")&&!r?.length){Promise.reject(s)}i(this,et,"f").call(this,s);i(this,rt,"f").call(this,s);this._emit("end")}}_emitFinal(){const e=this.receivedMessages.at(-1);if(e){this._emit("finalMessage",i(this,F,"m",pr).call(this))}}async _fromReadableStream(e,t){const r=t?.signal;let s;if(r){if(r.aborted)this.controller.abort();s=this.controller.abort.bind(this.controller);r.addEventListener("abort",s)}try{i(this,F,"m",fr).call(this);this._connected(null);const o=U.fromReadableStream(e,this.controller);for await(const a of o){i(this,F,"m",mr).call(this,a)}if(o.controller.signal?.aborted){throw new T}i(this,F,"m",gr).call(this)}finally{if(r&&s){r.removeEventListener("abort",s)}}}[(Y=new WeakMap,Ce=new WeakMap,Ze=new WeakMap,Mt=new WeakMap,et=new WeakMap,tt=new WeakMap,Tt=new WeakMap,rt=new WeakMap,J=new WeakMap,st=new WeakMap,It=new WeakMap,Ct=new WeakMap,ae=new WeakMap,$t=new WeakMap,Ot=new WeakMap,nt=new WeakMap,Bt=new WeakMap,F=new WeakSet,pr=function e(){if(this.receivedMessages.length===0){throw new g("stream ended without producing a Message with role=assistant")}return this.receivedMessages.at(-1)},hs=function e(){if(this.receivedMessages.length===0){throw new g("stream ended without producing a Message with role=assistant")}const t=this.receivedMessages.at(-1).content.filter(r=>r.type==="text").map(r=>r.text);if(t.length===0){throw new g("stream ended without producing a content block with type=text")}return t.join(" ")},fr=function e(){if(this.ended)return;p(this,Y,void 0,"f")},mr=function e(t){if(this.ended)return;const r=i(this,F,"m",ds).call(this,t);this._emit("streamEvent",t,r);switch(t.type){case"content_block_delta":{const s=r.content.at(-1);switch(t.delta.type){case"text_delta":{if(s.type==="text"){this._emit("text",t.delta.text,s.text||"")}break}case"citations_delta":{if(s.type==="text"){this._emit("citation",t.delta.citation,s.citations??[])}break}case"input_json_delta":{if(fs(s)&&s.input){this._emit("inputJson",t.delta.partial_json,s.input)}break}case"thinking_delta":{if(s.type==="thinking"){this._emit("thinking",t.delta.thinking,s.thinking)}break}case"signature_delta":{if(s.type==="thinking"){this._emit("signature",s.signature)}break}case"compaction_delta":{if(s.type==="compaction"&&s.content){this._emit("compaction",s.content)}break}default:ms(t.delta)}break}case"message_stop":{this._addMessageParam(r);this._addMessage(hr(r,i(this,Ce,"f"),{logger:i(this,nt,"f")}),true);break}case"content_block_stop":{this._emit("contentBlock",r.content.at(-1));break}case"message_start":{p(this,Y,r,"f");break}case"content_block_start":case"message_delta":break}},gr=function e(){if(this.ended){throw new g(`stream has ended, this shouldn't happen`)}const t=i(this,Y,"f");if(!t){throw new g(`request ended without sending any chunks`)}p(this,Y,void 0,"f");return hr(t,i(this,Ce,"f"),{logger:i(this,nt,"f")})},ds=function e(t){let r=i(this,Y,"f");if(t.type==="message_start"){if(r){throw new g(`Unexpected event order, got ${t.type} before receiving "message_stop"`)}return t.message}if(!r){throw new g(`Unexpected event order, got ${t.type} before "message_start"`)}switch(t.type){case"message_stop":return r;case"message_delta":r.container=t.delta.container;r.stop_reason=t.delta.stop_reason;r.stop_sequence=t.delta.stop_sequence;r.usage.output_tokens=t.usage.output_tokens;r.context_management=t.context_management;if(t.usage.input_tokens!=null){r.usage.input_tokens=t.usage.input_tokens}if(t.usage.cache_creation_input_tokens!=null){r.usage.cache_creation_input_tokens=t.usage.cache_creation_input_tokens}if(t.usage.cache_read_input_tokens!=null){r.usage.cache_read_input_tokens=t.usage.cache_read_input_tokens}if(t.usage.server_tool_use!=null){r.usage.server_tool_use=t.usage.server_tool_use}if(t.usage.iterations!=null){r.usage.iterations=t.usage.iterations}return r;case"content_block_start":r.content.push(t.content_block);return r;case"content_block_delta":{const s=r.content.at(t.index);switch(t.delta.type){case"text_delta":{if(s?.type==="text"){r.content[t.index]={...s,text:(s.text||"")+t.delta.text}}break}case"citations_delta":{if(s?.type==="text"){r.content[t.index]={...s,citations:[...s.citations??[],t.delta.citation]}}break}case"input_json_delta":{if(s&&fs(s)){let o=s[ps]||"";o+=t.delta.partial_json;const a={...s};Object.defineProperty(a,ps,{value:o,enumerable:false,writable:true});if(o){try{a.input=Rt(o)}catch(c){const l=new g(`Unable to parse tool parameter JSON from model. Please retry your request or adjust your prompt. Error: ${c}. JSON: ${o}`);i(this,Bt,"f").call(this,l)}}r.content[t.index]=a}break}case"thinking_delta":{if(s?.type==="thinking"){r.content[t.index]={...s,thinking:s.thinking+t.delta.thinking}}break}case"signature_delta":{if(s?.type==="thinking"){r.content[t.index]={...s,signature:t.delta.signature}}break}case"compaction_delta":{if(s?.type==="compaction"){r.content[t.index]={...s,content:(s.content||"")+t.delta.content}}break}default:ms(t.delta)}return r}case"content_block_stop":return r}},Symbol.asyncIterator)](){const e=[];const t=[];let r=false;this.on("streamEvent",s=>{const o=t.shift();if(o){o.resolve(s)}else{e.push(s)}});this.on("end",()=>{r=true;for(const s of t){s.resolve(void 0)}t.length=0});this.on("abort",s=>{r=true;for(const o of t){o.reject(s)}t.length=0});this.on("error",s=>{r=true;for(const o of t){o.reject(s)}t.length=0});return{next:async()=>{if(!e.length){if(r){return{value:void 0,done:true}}return new Promise((o,a)=>t.push({resolve:o,reject:a})).then(o=>o?{value:o,done:false}:{value:void 0,done:true})}const s=e.shift();return{value:s,done:false}},return:async()=>{this.abort();return{value:void 0,done:true}}}}toReadableStream(){const e=new U(this[Symbol.asyncIterator].bind(this),this.controller);return e.toReadableStream()}};function ms(n){}var ie=class extends Error{constructor(e){const t=typeof e==="string"?e:e.map(r=>{if(r.type==="text")return r.text;return`[${r.type}]`}).join(" ");super(t);this.name="ToolError";this.content=e}};var gs=1e5;var _s=`You have been working on the task described above but have not yet completed it. Write a continuation summary that will allow you (or another instance of yourself) to resume work efficiently in a future context window where the conversation history will be replaced with this summary. Your summary should be structured, concise, and actionable. Include:
|
|
6
|
+
1. Task Overview
|
|
7
|
+
The user's core request and success criteria
|
|
8
|
+
Any clarifications or constraints they specified
|
|
9
|
+
2. Current State
|
|
10
|
+
What has been completed so far
|
|
11
|
+
Files created, modified, or analyzed (with paths if relevant)
|
|
12
|
+
Key outputs or artifacts produced
|
|
13
|
+
3. Important Discoveries
|
|
14
|
+
Technical constraints or requirements uncovered
|
|
15
|
+
Decisions made and their rationale
|
|
16
|
+
Errors encountered and how they were resolved
|
|
17
|
+
What approaches were tried that didn't work (and why)
|
|
18
|
+
4. Next Steps
|
|
19
|
+
Specific actions needed to complete the task
|
|
20
|
+
Any blockers or open questions to resolve
|
|
21
|
+
Priority order if multiple steps remain
|
|
22
|
+
5. Context to Preserve
|
|
23
|
+
User preferences or style requirements
|
|
24
|
+
Domain-specific details that aren't obvious
|
|
25
|
+
Any promises made to the user
|
|
26
|
+
Be concise but complete\u2014err on the side of including information that would prevent duplicate work or repeated mistakes. Write in a way that enables immediate resumption of the task.
|
|
27
|
+
Wrap your summary in <summary></summary> tags.`;var ot;var $e;var ce;var P;var C;var B;var V;var Z;var at;var bs;var _r;function ys(){let n;let e;const t=new Promise((r,s)=>{n=r;e=s});return{promise:t,resolve:n,reject:e}}var Oe=class{constructor(e,t,r){ot.add(this);this.client=e;$e.set(this,false);ce.set(this,false);P.set(this,void 0);C.set(this,void 0);B.set(this,void 0);V.set(this,void 0);Z.set(this,void 0);at.set(this,0);p(this,P,{params:{...t,messages:structuredClone(t.messages)}},"f");const s=ur(t.tools,t.messages);const o=["BetaToolRunner",...s].join(", ");p(this,C,{...r,headers:u([{"x-stainless-helper":o},r?.headers])},"f");p(this,Z,ys(),"f");if(t.compactionControl?.enabled){console.warn('Anthropic: The `compactionControl` parameter is deprecated and will be removed in a future version. Use server-side compaction instead by passing `edits: [{ type: "compact_20260112" }]` in the params passed to `toolRunner()`. See https://platform.claude.com/docs/en/build-with-claude/compaction')}}async*[($e=new WeakMap,ce=new WeakMap,P=new WeakMap,C=new WeakMap,B=new WeakMap,V=new WeakMap,Z=new WeakMap,at=new WeakMap,ot=new WeakSet,bs=async function e(){const t=i(this,P,"f").params.compactionControl;if(!t||!t.enabled){return false}let r=0;if(i(this,B,"f")!==void 0){try{const h=await i(this,B,"f");const f=h.usage.input_tokens+(h.usage.cache_creation_input_tokens??0)+(h.usage.cache_read_input_tokens??0);r=f+h.usage.output_tokens}catch{return false}}const s=t.contextTokenThreshold??gs;if(r<s){return false}const o=t.model??i(this,P,"f").params.model;const a=t.summaryPrompt??_s;const c=i(this,P,"f").params.messages;if(c[c.length-1].role==="assistant"){const h=c[c.length-1];if(Array.isArray(h.content)){const f=h.content.filter(m=>m.type!=="tool_use");if(f.length===0){c.pop()}else{h.content=f}}}const l=await this.client.beta.messages.create({model:o,messages:[...c,{role:"user",content:[{type:"text",text:a}]}],max_tokens:i(this,P,"f").params.max_tokens},{signal:i(this,C,"f").signal,headers:u([i(this,C,"f").headers,{"x-stainless-helper":"compaction"}])});if(l.content[0]?.type!=="text"){throw new g("Expected text response for compaction")}i(this,P,"f").params.messages=[{role:"user",content:l.content}];return true},Symbol.asyncIterator)](){var e;if(i(this,$e,"f")){throw new g("Cannot iterate over a consumed stream")}p(this,$e,true,"f");p(this,ce,true,"f");p(this,V,void 0,"f");try{while(true){let t;try{if(i(this,P,"f").params.max_iterations&&i(this,at,"f")>=i(this,P,"f").params.max_iterations){break}p(this,ce,false,"f");p(this,V,void 0,"f");p(this,at,(e=i(this,at,"f"),e++,e),"f");p(this,B,void 0,"f");const{max_iterations:r,compactionControl:s,...o}=i(this,P,"f").params;if(o.stream){t=this.client.beta.messages.stream({...o},i(this,C,"f"));p(this,B,t.finalMessage(),"f");i(this,B,"f").catch(()=>{});yield t}else{p(this,B,this.client.beta.messages.create({...o,stream:false},i(this,C,"f")),"f");yield i(this,B,"f")}const a=await i(this,ot,"m",bs).call(this);if(!a){if(!i(this,ce,"f")){const{role:l,content:h}=await i(this,B,"f");i(this,P,"f").params.messages.push({role:l,content:h})}const c=await i(this,ot,"m",_r).call(this,i(this,P,"f").params.messages.at(-1));if(c){i(this,P,"f").params.messages.push(c)}else if(!i(this,ce,"f")){break}}}finally{if(t){t.abort()}}}if(!i(this,B,"f")){throw new g("ToolRunner concluded without a message from the server")}i(this,Z,"f").resolve(await i(this,B,"f"))}catch(t){p(this,$e,false,"f");i(this,Z,"f").promise.catch(()=>{});i(this,Z,"f").reject(t);p(this,Z,ys(),"f");throw t}}setMessagesParams(e){if(typeof e==="function"){i(this,P,"f").params=e(i(this,P,"f").params)}else{i(this,P,"f").params=e}p(this,ce,true,"f");p(this,V,void 0,"f")}setRequestOptions(e){if(typeof e==="function"){p(this,C,e(i(this,C,"f")),"f")}else{p(this,C,{...i(this,C,"f"),...e},"f")}}async generateToolResponse(e=i(this,C,"f").signal){const t=await i(this,B,"f")??this.params.messages.at(-1);if(!t){return null}return i(this,ot,"m",_r).call(this,t,e)}done(){return i(this,Z,"f").promise}async runUntilDone(){if(!i(this,$e,"f")){for await(const e of this){}}return this.done()}get params(){return i(this,P,"f").params}pushMessages(...e){this.setMessagesParams(t=>({...t,messages:[...t.messages,...e]}))}then(e,t){return this.runUntilDone().then(e,t)}};_r=async function n(e,t=i(this,C,"f").signal){if(i(this,V,"f")!==void 0){return i(this,V,"f")}p(this,V,xn(i(this,P,"f").params,e,{...i(this,C,"f"),signal:t}),"f");return i(this,V,"f")};async function xn(n,e=n.messages.at(-1),t){if(!e||e.role!=="assistant"||!e.content||typeof e.content==="string"){return null}const r=e.content.filter(o=>o.type==="tool_use");if(r.length===0){return null}const s=await Promise.all(r.map(async o=>{const a=n.tools.find(c=>("name"in c?c.name:c.mcp_server_name)===o.name);if(!a||!("run"in a)){return{type:"tool_result",tool_use_id:o.id,content:`Error: Tool '${o.name}' not found`,is_error:true}}try{let c=o.input;if("parse"in a&&a.parse){c=a.parse(c)}const l=await a.run(c,{toolUseBlock:o,signal:t?.signal});return{type:"tool_result",tool_use_id:o.id,content:l}}catch(c){return{type:"tool_result",tool_use_id:o.id,content:c instanceof ie?c.content:`Error: ${c instanceof Error?c.message:String(c)}`,is_error:true}}}));return{role:"user",content:s}}var Be=class n{constructor(e,t){this.iterator=e;this.controller=t}async*decoder(){const e=new D;for await(const t of this.iterator){for(const r of e.decode(t)){yield JSON.parse(r)}}for(const t of e.flush()){yield JSON.parse(t)}}[Symbol.asyncIterator](){return this.decoder()}static fromResponse(e,t){if(!e.body){t.abort();if(typeof globalThis.navigator!=="undefined"&&globalThis.navigator.product==="ReactNative"){throw new g(`The default react-native fetch implementation does not support streaming. Please use expo/fetch: https://docs.expo.dev/versions/latest/sdk/expo/#expofetch-api`)}throw new g(`Attempted to iterate over a response with no body`)}return new n(Je(e.body),t)}};var Le=class extends y{create(e,t){const{betas:r,...s}=e;return this._client.post("/v1/messages/batches?beta=true",{body:s,...t,headers:u([{"anthropic-beta":[...r??[],"message-batches-2024-09-24"].toString()},t?.headers])})}retrieve(e,t={},r){const{betas:s}=t??{};return this._client.get(d`/v1/messages/batches/${e}?beta=true`,{...r,headers:u([{"anthropic-beta":[...s??[],"message-batches-2024-09-24"].toString()},r?.headers])})}list(e={},t){const{betas:r,...s}=e??{};return this._client.getAPIList("/v1/messages/batches?beta=true",N,{query:s,...t,headers:u([{"anthropic-beta":[...r??[],"message-batches-2024-09-24"].toString()},t?.headers])})}delete(e,t={},r){const{betas:s}=t??{};return this._client.delete(d`/v1/messages/batches/${e}?beta=true`,{...r,headers:u([{"anthropic-beta":[...s??[],"message-batches-2024-09-24"].toString()},r?.headers])})}cancel(e,t={},r){const{betas:s}=t??{};return this._client.post(d`/v1/messages/batches/${e}/cancel?beta=true`,{...r,headers:u([{"anthropic-beta":[...s??[],"message-batches-2024-09-24"].toString()},r?.headers])})}async results(e,t={},r){const s=await this.retrieve(e);if(!s.results_url){throw new g(`No batch \`results_url\`; Has it finished processing? ${s.processing_status} - ${s.id}`)}const{betas:o}=t??{};return this._client.get(s.results_url,{...r,headers:u([{"anthropic-beta":[...o??[],"message-batches-2024-09-24"].toString(),Accept:"application/binary"},r?.headers]),stream:true,__binaryResponse:true})._thenUnwrap((a,c)=>Be.fromResponse(c.response,c.controller))}};var ws={"claude-1.3":"November 6th, 2024","claude-1.3-100k":"November 6th, 2024","claude-instant-1.1":"November 6th, 2024","claude-instant-1.1-100k":"November 6th, 2024","claude-instant-1.2":"November 6th, 2024","claude-3-sonnet-20240229":"July 21st, 2025","claude-3-opus-20240229":"January 5th, 2026","claude-2.1":"July 21st, 2025","claude-2.0":"July 21st, 2025","claude-3-7-sonnet-latest":"February 19th, 2026","claude-3-7-sonnet-20250219":"February 19th, 2026"};var kn=["claude-mythos-preview","claude-opus-4-6"];var X=class extends y{constructor(){super(...arguments);this.batches=new Le(this._client)}create(e,t){const r=xs(e);const{betas:s,...o}=r;if(o.model in ws){console.warn(`The model '${o.model}' is deprecated and will reach end-of-life on ${ws[o.model]}
|
|
28
|
+
Please migrate to a newer model. Visit https://docs.anthropic.com/en/docs/resources/model-deprecations for more information.`)}if(kn.includes(o.model)&&o.thinking&&o.thinking.type==="enabled"){console.warn(`Using Claude with ${o.model} and 'thinking.type=enabled' is deprecated. Use 'thinking.type=adaptive' instead which results in better model performance in our testing: https://platform.claude.com/docs/en/build-with-claude/adaptive-thinking`)}let a=this._client._options.timeout;if(!o.stream&&a==null){const l=Et[o.model]??void 0;a=this._client.calculateNonstreamingTimeout(o.max_tokens,l)}const c=Pt(o.tools,o.messages);return this._client.post("/v1/messages?beta=true",{body:o,timeout:a??6e5,...t,headers:u([{...s?.toString()!=null?{"anthropic-beta":s?.toString()}:void 0},c,t?.headers]),stream:r.stream??false})}parse(e,t){t={...t,headers:u([{"anthropic-beta":[...e.betas??[],"structured-outputs-2025-12-15"].toString()},t?.headers])};return this.create(e,t).then(r=>dr(r,e,{logger:this._client.logger??console}))}stream(e,t){return Lt.createMessage(this,e,t)}countTokens(e,t){const r=xs(e);const{betas:s,...o}=r;return this._client.post("/v1/messages/count_tokens?beta=true",{body:o,...t,headers:u([{"anthropic-beta":[...s??[],"token-counting-2024-11-01"].toString()},t?.headers])})}toolRunner(e,t){return new Oe(this._client,e,t)}};function xs(n){if(!n.output_format){return n}if(n.output_config?.format){throw new g("Both output_format and output_config.format were provided. Please use only output_config.format (output_format is deprecated).")}const{output_format:e,...t}=n;return{...t,output_config:{...n.output_config,format:e}}}X.Batches=Le;X.BetaToolRunner=Oe;X.ToolError=ie;var Ne=class extends y{list(e,t={},r){const{betas:s,...o}=t??{};return this._client.getAPIList(d`/v1/sessions/${e}/events?beta=true`,k,{query:o,...r,headers:u([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString()},r?.headers])})}send(e,t,r){const{betas:s,...o}=t;return this._client.post(d`/v1/sessions/${e}/events?beta=true`,{body:o,...r,headers:u([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString()},r?.headers])})}stream(e,t={},r){const{betas:s}=t??{};return this._client.get(d`/v1/sessions/${e}/events/stream?beta=true`,{...r,headers:u([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString()},r?.headers]),stream:true})}};var Fe=class extends y{retrieve(e,t,r){const{session_id:s,betas:o}=t;return this._client.get(d`/v1/sessions/${s}/resources/${e}?beta=true`,{...r,headers:u([{"anthropic-beta":[...o??[],"managed-agents-2026-04-01"].toString()},r?.headers])})}update(e,t,r){const{session_id:s,betas:o,...a}=t;return this._client.post(d`/v1/sessions/${s}/resources/${e}?beta=true`,{body:a,...r,headers:u([{"anthropic-beta":[...o??[],"managed-agents-2026-04-01"].toString()},r?.headers])})}list(e,t={},r){const{betas:s,...o}=t??{};return this._client.getAPIList(d`/v1/sessions/${e}/resources?beta=true`,k,{query:o,...r,headers:u([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString()},r?.headers])})}delete(e,t,r){const{session_id:s,betas:o}=t;return this._client.delete(d`/v1/sessions/${s}/resources/${e}?beta=true`,{...r,headers:u([{"anthropic-beta":[...o??[],"managed-agents-2026-04-01"].toString()},r?.headers])})}add(e,t,r){const{betas:s,...o}=t;return this._client.post(d`/v1/sessions/${e}/resources?beta=true`,{body:o,...r,headers:u([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString()},r?.headers])})}};var ee=class extends y{constructor(){super(...arguments);this.events=new Ne(this._client);this.resources=new Fe(this._client)}create(e,t){const{betas:r,...s}=e;return this._client.post("/v1/sessions?beta=true",{body:s,...t,headers:u([{"anthropic-beta":[...r??[],"managed-agents-2026-04-01"].toString()},t?.headers])})}retrieve(e,t={},r){const{betas:s}=t??{};return this._client.get(d`/v1/sessions/${e}?beta=true`,{...r,headers:u([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString()},r?.headers])})}update(e,t,r){const{betas:s,...o}=t;return this._client.post(d`/v1/sessions/${e}?beta=true`,{body:o,...r,headers:u([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString()},r?.headers])})}list(e={},t){const{betas:r,...s}=e??{};return this._client.getAPIList("/v1/sessions?beta=true",k,{query:s,...t,headers:u([{"anthropic-beta":[...r??[],"managed-agents-2026-04-01"].toString()},t?.headers])})}delete(e,t={},r){const{betas:s}=t??{};return this._client.delete(d`/v1/sessions/${e}?beta=true`,{...r,headers:u([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString()},r?.headers])})}archive(e,t={},r){const{betas:s}=t??{};return this._client.post(d`/v1/sessions/${e}/archive?beta=true`,{...r,headers:u([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString()},r?.headers])})}};ee.Events=Ne;ee.Resources=Fe;var je=class extends y{create(e,t={},r){const{betas:s,...o}=t??{};return this._client.post(d`/v1/skills/${e}/versions?beta=true`,ke({body:o,...r,headers:u([{"anthropic-beta":[...s??[],"skills-2025-10-02"].toString()},r?.headers])},this._client))}retrieve(e,t,r){const{skill_id:s,betas:o}=t;return this._client.get(d`/v1/skills/${s}/versions/${e}?beta=true`,{...r,headers:u([{"anthropic-beta":[...o??[],"skills-2025-10-02"].toString()},r?.headers])})}list(e,t={},r){const{betas:s,...o}=t??{};return this._client.getAPIList(d`/v1/skills/${e}/versions?beta=true`,k,{query:o,...r,headers:u([{"anthropic-beta":[...s??[],"skills-2025-10-02"].toString()},r?.headers])})}delete(e,t,r){const{skill_id:s,betas:o}=t;return this._client.delete(d`/v1/skills/${s}/versions/${e}?beta=true`,{...r,headers:u([{"anthropic-beta":[...o??[],"skills-2025-10-02"].toString()},r?.headers])})}};var le=class extends y{constructor(){super(...arguments);this.versions=new je(this._client)}create(e={},t){const{betas:r,...s}=e??{};return this._client.post("/v1/skills?beta=true",ke({body:s,...t,headers:u([{"anthropic-beta":[...r??[],"skills-2025-10-02"].toString()},t?.headers])},this._client,false))}retrieve(e,t={},r){const{betas:s}=t??{};return this._client.get(d`/v1/skills/${e}?beta=true`,{...r,headers:u([{"anthropic-beta":[...s??[],"skills-2025-10-02"].toString()},r?.headers])})}list(e={},t){const{betas:r,...s}=e??{};return this._client.getAPIList("/v1/skills?beta=true",k,{query:s,...t,headers:u([{"anthropic-beta":[...r??[],"skills-2025-10-02"].toString()},t?.headers])})}delete(e,t={},r){const{betas:s}=t??{};return this._client.delete(d`/v1/skills/${e}?beta=true`,{...r,headers:u([{"anthropic-beta":[...s??[],"skills-2025-10-02"].toString()},r?.headers])})}};le.Versions=je;var qe=class extends y{create(e,t,r){const{betas:s,...o}=t;return this._client.post(d`/v1/vaults/${e}/credentials?beta=true`,{body:o,...r,headers:u([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString()},r?.headers])})}retrieve(e,t,r){const{vault_id:s,betas:o}=t;return this._client.get(d`/v1/vaults/${s}/credentials/${e}?beta=true`,{...r,headers:u([{"anthropic-beta":[...o??[],"managed-agents-2026-04-01"].toString()},r?.headers])})}update(e,t,r){const{vault_id:s,betas:o,...a}=t;return this._client.post(d`/v1/vaults/${s}/credentials/${e}?beta=true`,{body:a,...r,headers:u([{"anthropic-beta":[...o??[],"managed-agents-2026-04-01"].toString()},r?.headers])})}list(e,t={},r){const{betas:s,...o}=t??{};return this._client.getAPIList(d`/v1/vaults/${e}/credentials?beta=true`,k,{query:o,...r,headers:u([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString()},r?.headers])})}delete(e,t,r){const{vault_id:s,betas:o}=t;return this._client.delete(d`/v1/vaults/${s}/credentials/${e}?beta=true`,{...r,headers:u([{"anthropic-beta":[...o??[],"managed-agents-2026-04-01"].toString()},r?.headers])})}archive(e,t,r){const{vault_id:s,betas:o}=t;return this._client.post(d`/v1/vaults/${s}/credentials/${e}/archive?beta=true`,{...r,headers:u([{"anthropic-beta":[...o??[],"managed-agents-2026-04-01"].toString()},r?.headers])})}};var ue=class extends y{constructor(){super(...arguments);this.credentials=new qe(this._client)}create(e,t){const{betas:r,...s}=e;return this._client.post("/v1/vaults?beta=true",{body:s,...t,headers:u([{"anthropic-beta":[...r??[],"managed-agents-2026-04-01"].toString()},t?.headers])})}retrieve(e,t={},r){const{betas:s}=t??{};return this._client.get(d`/v1/vaults/${e}?beta=true`,{...r,headers:u([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString()},r?.headers])})}update(e,t,r){const{betas:s,...o}=t;return this._client.post(d`/v1/vaults/${e}?beta=true`,{body:o,...r,headers:u([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString()},r?.headers])})}list(e={},t){const{betas:r,...s}=e??{};return this._client.getAPIList("/v1/vaults?beta=true",k,{query:s,...t,headers:u([{"anthropic-beta":[...r??[],"managed-agents-2026-04-01"].toString()},t?.headers])})}delete(e,t={},r){const{betas:s}=t??{};return this._client.delete(d`/v1/vaults/${e}?beta=true`,{...r,headers:u([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString()},r?.headers])})}archive(e,t={},r){const{betas:s}=t??{};return this._client.post(d`/v1/vaults/${e}/archive?beta=true`,{...r,headers:u([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString()},r?.headers])})}};ue.Credentials=qe;var I=class extends y{constructor(){super(...arguments);this.models=new Pe(this._client);this.messages=new X(this._client);this.agents=new oe(this._client);this.environments=new ve(this._client);this.sessions=new ee(this._client);this.vaults=new ue(this._client);this.memoryStores=new Q(this._client);this.files=new Ae(this._client);this.skills=new le(this._client);this.userProfiles=new Ee(this._client)}};I.Models=Pe;I.Messages=X;I.Agents=oe;I.Environments=ve;I.Sessions=ee;I.Vaults=ue;I.MemoryStores=Q;I.Files=Ae;I.Skills=le;I.UserProfiles=Ee;var he=class extends y{create(e,t){const{betas:r,...s}=e;return this._client.post("/v1/complete",{body:s,timeout:this._client._options.timeout??6e5,...t,headers:u([{...r?.toString()!=null?{"anthropic-beta":r?.toString()}:void 0},t?.headers]),stream:e.stream??false})}};function Ss(n){return n?.output_config?.format}function br(n,e,t){const r=Ss(e);if(!e||!("parse"in(r??{}))){return{...n,content:n.content.map(s=>{if(s.type==="text"){const o=Object.defineProperty({...s},"parsed_output",{value:null,enumerable:false});return o}return s}),parsed_output:null}}return yr(n,e,t)}function yr(n,e,t){let r=null;const s=n.content.map(o=>{if(o.type==="text"){const a=Cn(e,o.text);if(r===null){r=a}const c=Object.defineProperty({...o},"parsed_output",{value:a,enumerable:false});return c}return o});return{...n,content:s,parsed_output:r}}function Cn(n,e){const t=Ss(n);if(t?.type!=="json_schema"){return null}try{if("parse"in t){return t.parse(e)}return JSON.parse(e)}catch(r){throw new g(`Failed to parse structured output: ${r}`)}}var j;var te;var Ue;var it;var Nt;var ct;var lt;var Ft;var ut;var K;var ht;var jt;var qt;var de;var Ut;var Ht;var dt;var wr;var ks;var xr;var Sr;var kr;var vr;var vs;var As="__json_buf";function Ps(n){return n.type==="tool_use"||n.type==="server_tool_use"}var Dt=class n{constructor(e,t){j.add(this);this.messages=[];this.receivedMessages=[];te.set(this,void 0);Ue.set(this,null);this.controller=new AbortController;it.set(this,void 0);Nt.set(this,()=>{});ct.set(this,()=>{});lt.set(this,void 0);Ft.set(this,()=>{});ut.set(this,()=>{});K.set(this,{});ht.set(this,false);jt.set(this,false);qt.set(this,false);de.set(this,false);Ut.set(this,void 0);Ht.set(this,void 0);dt.set(this,void 0);xr.set(this,r=>{p(this,jt,true,"f");if(H(r)){r=new T}if(r instanceof T){p(this,qt,true,"f");return this._emit("abort",r)}if(r instanceof g){return this._emit("error",r)}if(r instanceof Error){const s=new g(r.message);s.cause=r;return this._emit("error",s)}return this._emit("error",new g(String(r)))});p(this,it,new Promise((r,s)=>{p(this,Nt,r,"f");p(this,ct,s,"f")}),"f");p(this,lt,new Promise((r,s)=>{p(this,Ft,r,"f");p(this,ut,s,"f")}),"f");i(this,it,"f").catch(()=>{});i(this,lt,"f").catch(()=>{});p(this,Ue,e,"f");p(this,dt,t?.logger??console,"f")}get response(){return i(this,Ut,"f")}get request_id(){return i(this,Ht,"f")}async withResponse(){p(this,de,true,"f");const e=await i(this,it,"f");if(!e){throw new Error("Could not resolve a `Response` object")}return{data:this,response:e,request_id:e.headers.get("request-id")}}static fromReadableStream(e){const t=new n(null);t._run(()=>t._fromReadableStream(e));return t}static createMessage(e,t,r,{logger:s}={}){const o=new n(t,{logger:s});for(const a of t.messages){o._addMessageParam(a)}p(o,Ue,{...t,stream:true},"f");o._run(()=>o._createMessage(e,{...t,stream:true},{...r,headers:{...r?.headers,"X-Stainless-Helper-Method":"stream"}}));return o}_run(e){e().then(()=>{this._emitFinal();this._emit("end")},i(this,xr,"f"))}_addMessageParam(e){this.messages.push(e)}_addMessage(e,t=true){this.receivedMessages.push(e);if(t){this._emit("message",e)}}async _createMessage(e,t,r){const s=r?.signal;let o;if(s){if(s.aborted)this.controller.abort();o=this.controller.abort.bind(this.controller);s.addEventListener("abort",o)}try{i(this,j,"m",Sr).call(this);const{response:a,data:c}=await e.create({...t,stream:true},{...r,signal:this.controller.signal}).withResponse();this._connected(a);for await(const l of c){i(this,j,"m",kr).call(this,l)}if(c.controller.signal?.aborted){throw new T}i(this,j,"m",vr).call(this)}finally{if(s&&o){s.removeEventListener("abort",o)}}}_connected(e){if(this.ended)return;p(this,Ut,e,"f");p(this,Ht,e?.headers.get("request-id"),"f");i(this,Nt,"f").call(this,e);this._emit("connect")}get ended(){return i(this,ht,"f")}get errored(){return i(this,jt,"f")}get aborted(){return i(this,qt,"f")}abort(){this.controller.abort()}on(e,t){const r=i(this,K,"f")[e]||(i(this,K,"f")[e]=[]);r.push({listener:t});return this}off(e,t){const r=i(this,K,"f")[e];if(!r)return this;const s=r.findIndex(o=>o.listener===t);if(s>=0)r.splice(s,1);return this}once(e,t){const r=i(this,K,"f")[e]||(i(this,K,"f")[e]=[]);r.push({listener:t,once:true});return this}emitted(e){return new Promise((t,r)=>{p(this,de,true,"f");if(e!=="error")this.once("error",r);this.once(e,t)})}async done(){p(this,de,true,"f");await i(this,lt,"f")}get currentMessage(){return i(this,te,"f")}async finalMessage(){await this.done();return i(this,j,"m",wr).call(this)}async finalText(){await this.done();return i(this,j,"m",ks).call(this)}_emit(e,...t){if(i(this,ht,"f"))return;if(e==="end"){p(this,ht,true,"f");i(this,Ft,"f").call(this)}const r=i(this,K,"f")[e];if(r){i(this,K,"f")[e]=r.filter(s=>!s.once);r.forEach(({listener:s})=>s(...t))}if(e==="abort"){const s=t[0];if(!i(this,de,"f")&&!r?.length){Promise.reject(s)}i(this,ct,"f").call(this,s);i(this,ut,"f").call(this,s);this._emit("end");return}if(e==="error"){const s=t[0];if(!i(this,de,"f")&&!r?.length){Promise.reject(s)}i(this,ct,"f").call(this,s);i(this,ut,"f").call(this,s);this._emit("end")}}_emitFinal(){const e=this.receivedMessages.at(-1);if(e){this._emit("finalMessage",i(this,j,"m",wr).call(this))}}async _fromReadableStream(e,t){const r=t?.signal;let s;if(r){if(r.aborted)this.controller.abort();s=this.controller.abort.bind(this.controller);r.addEventListener("abort",s)}try{i(this,j,"m",Sr).call(this);this._connected(null);const o=U.fromReadableStream(e,this.controller);for await(const a of o){i(this,j,"m",kr).call(this,a)}if(o.controller.signal?.aborted){throw new T}i(this,j,"m",vr).call(this)}finally{if(r&&s){r.removeEventListener("abort",s)}}}[(te=new WeakMap,Ue=new WeakMap,it=new WeakMap,Nt=new WeakMap,ct=new WeakMap,lt=new WeakMap,Ft=new WeakMap,ut=new WeakMap,K=new WeakMap,ht=new WeakMap,jt=new WeakMap,qt=new WeakMap,de=new WeakMap,Ut=new WeakMap,Ht=new WeakMap,dt=new WeakMap,xr=new WeakMap,j=new WeakSet,wr=function e(){if(this.receivedMessages.length===0){throw new g("stream ended without producing a Message with role=assistant")}return this.receivedMessages.at(-1)},ks=function e(){if(this.receivedMessages.length===0){throw new g("stream ended without producing a Message with role=assistant")}const t=this.receivedMessages.at(-1).content.filter(r=>r.type==="text").map(r=>r.text);if(t.length===0){throw new g("stream ended without producing a content block with type=text")}return t.join(" ")},Sr=function e(){if(this.ended)return;p(this,te,void 0,"f")},kr=function e(t){if(this.ended)return;const r=i(this,j,"m",vs).call(this,t);this._emit("streamEvent",t,r);switch(t.type){case"content_block_delta":{const s=r.content.at(-1);switch(t.delta.type){case"text_delta":{if(s.type==="text"){this._emit("text",t.delta.text,s.text||"")}break}case"citations_delta":{if(s.type==="text"){this._emit("citation",t.delta.citation,s.citations??[])}break}case"input_json_delta":{if(Ps(s)&&s.input){this._emit("inputJson",t.delta.partial_json,s.input)}break}case"thinking_delta":{if(s.type==="thinking"){this._emit("thinking",t.delta.thinking,s.thinking)}break}case"signature_delta":{if(s.type==="thinking"){this._emit("signature",s.signature)}break}default:Es(t.delta)}break}case"message_stop":{this._addMessageParam(r);this._addMessage(br(r,i(this,Ue,"f"),{logger:i(this,dt,"f")}),true);break}case"content_block_stop":{this._emit("contentBlock",r.content.at(-1));break}case"message_start":{p(this,te,r,"f");break}case"content_block_start":case"message_delta":break}},vr=function e(){if(this.ended){throw new g(`stream has ended, this shouldn't happen`)}const t=i(this,te,"f");if(!t){throw new g(`request ended without sending any chunks`)}p(this,te,void 0,"f");return br(t,i(this,Ue,"f"),{logger:i(this,dt,"f")})},vs=function e(t){let r=i(this,te,"f");if(t.type==="message_start"){if(r){throw new g(`Unexpected event order, got ${t.type} before receiving "message_stop"`)}return t.message}if(!r){throw new g(`Unexpected event order, got ${t.type} before "message_start"`)}switch(t.type){case"message_stop":return r;case"message_delta":r.stop_reason=t.delta.stop_reason;r.stop_sequence=t.delta.stop_sequence;r.usage.output_tokens=t.usage.output_tokens;if(t.usage.input_tokens!=null){r.usage.input_tokens=t.usage.input_tokens}if(t.usage.cache_creation_input_tokens!=null){r.usage.cache_creation_input_tokens=t.usage.cache_creation_input_tokens}if(t.usage.cache_read_input_tokens!=null){r.usage.cache_read_input_tokens=t.usage.cache_read_input_tokens}if(t.usage.server_tool_use!=null){r.usage.server_tool_use=t.usage.server_tool_use}return r;case"content_block_start":r.content.push({...t.content_block});return r;case"content_block_delta":{const s=r.content.at(t.index);switch(t.delta.type){case"text_delta":{if(s?.type==="text"){r.content[t.index]={...s,text:(s.text||"")+t.delta.text}}break}case"citations_delta":{if(s?.type==="text"){r.content[t.index]={...s,citations:[...s.citations??[],t.delta.citation]}}break}case"input_json_delta":{if(s&&Ps(s)){let o=s[As]||"";o+=t.delta.partial_json;const a={...s};Object.defineProperty(a,As,{value:o,enumerable:false,writable:true});if(o){a.input=Rt(o)}r.content[t.index]=a}break}case"thinking_delta":{if(s?.type==="thinking"){r.content[t.index]={...s,thinking:s.thinking+t.delta.thinking}}break}case"signature_delta":{if(s?.type==="thinking"){r.content[t.index]={...s,signature:t.delta.signature}}break}default:Es(t.delta)}return r}case"content_block_stop":return r}},Symbol.asyncIterator)](){const e=[];const t=[];let r=false;this.on("streamEvent",s=>{const o=t.shift();if(o){o.resolve(s)}else{e.push(s)}});this.on("end",()=>{r=true;for(const s of t){s.resolve(void 0)}t.length=0});this.on("abort",s=>{r=true;for(const o of t){o.reject(s)}t.length=0});this.on("error",s=>{r=true;for(const o of t){o.reject(s)}t.length=0});return{next:async()=>{if(!e.length){if(r){return{value:void 0,done:true}}return new Promise((o,a)=>t.push({resolve:o,reject:a})).then(o=>o?{value:o,done:false}:{value:void 0,done:true})}const s=e.shift();return{value:s,done:false}},return:async()=>{this.abort();return{value:void 0,done:true}}}}toReadableStream(){const e=new U(this[Symbol.asyncIterator].bind(this),this.controller);return e.toReadableStream()}};function Es(n){}var He=class extends y{create(e,t){return this._client.post("/v1/messages/batches",{body:e,...t})}retrieve(e,t){return this._client.get(d`/v1/messages/batches/${e}`,t)}list(e={},t){return this._client.getAPIList("/v1/messages/batches",N,{query:e,...t})}delete(e,t){return this._client.delete(d`/v1/messages/batches/${e}`,t)}cancel(e,t){return this._client.post(d`/v1/messages/batches/${e}/cancel`,t)}async results(e,t){const r=await this.retrieve(e);if(!r.results_url){throw new g(`No batch \`results_url\`; Has it finished processing? ${r.processing_status} - ${r.id}`)}return this._client.get(r.results_url,{...t,headers:u([{Accept:"application/binary"},t?.headers]),stream:true,__binaryResponse:true})._thenUnwrap((s,o)=>Be.fromResponse(o.response,o.controller))}};var re=class extends y{constructor(){super(...arguments);this.batches=new He(this._client)}create(e,t){if(e.model in Rs){console.warn(`The model '${e.model}' is deprecated and will reach end-of-life on ${Rs[e.model]}
|
|
29
|
+
Please migrate to a newer model. Visit https://docs.anthropic.com/en/docs/resources/model-deprecations for more information.`)}if(On.includes(e.model)&&e.thinking&&e.thinking.type==="enabled"){console.warn(`Using Claude with ${e.model} and 'thinking.type=enabled' is deprecated. Use 'thinking.type=adaptive' instead which results in better model performance in our testing: https://platform.claude.com/docs/en/build-with-claude/adaptive-thinking`)}let r=this._client._options.timeout;if(!e.stream&&r==null){const o=Et[e.model]??void 0;r=this._client.calculateNonstreamingTimeout(e.max_tokens,o)}const s=Pt(e.tools,e.messages);return this._client.post("/v1/messages",{body:e,timeout:r??6e5,...t,headers:u([s,t?.headers]),stream:e.stream??false})}parse(e,t){return this.create(e,t).then(r=>yr(r,e,{logger:this._client.logger??console}))}stream(e,t){return Dt.createMessage(this,e,t,{logger:this._client.logger??console})}countTokens(e,t){return this._client.post("/v1/messages/count_tokens",{body:e,...t})}};var Rs={"claude-1.3":"November 6th, 2024","claude-1.3-100k":"November 6th, 2024","claude-instant-1.1":"November 6th, 2024","claude-instant-1.1-100k":"November 6th, 2024","claude-instant-1.2":"November 6th, 2024","claude-3-sonnet-20240229":"July 21st, 2025","claude-3-opus-20240229":"January 5th, 2026","claude-2.1":"July 21st, 2025","claude-2.0":"July 21st, 2025","claude-3-7-sonnet-latest":"February 19th, 2026","claude-3-7-sonnet-20250219":"February 19th, 2026","claude-3-5-haiku-latest":"February 19th, 2026","claude-3-5-haiku-20241022":"February 19th, 2026","claude-opus-4-0":"June 15th, 2026","claude-opus-4-20250514":"June 15th, 2026","claude-sonnet-4-0":"June 15th, 2026","claude-sonnet-4-20250514":"June 15th, 2026"};var On=["claude-mythos-preview","claude-opus-4-6"];re.Batches=He;var pe=class extends y{retrieve(e,t={},r){const{betas:s}=t??{};return this._client.get(d`/v1/models/${e}`,{...r,headers:u([{...s?.toString()!=null?{"anthropic-beta":s?.toString()}:void 0},r?.headers])})}list(e={},t){const{betas:r,...s}=e??{};return this._client.getAPIList("/v1/models",N,{query:s,...t,headers:u([{...r?.toString()!=null?{"anthropic-beta":r?.toString()}:void 0},t?.headers])})}};var pt=n=>{if(typeof globalThis.process!=="undefined"){return globalThis.process.env?.[n]?.trim()||void 0}if(typeof globalThis.Deno!=="undefined"){return globalThis.Deno.env?.get?.(n)?.trim()||void 0}return void 0};var Ar;var Pr;var Wt;var Ms;var Ts="\\n\\nHuman:";var Is="\\n\\nAssistant:";var v=class{constructor({baseURL:e=pt("ANTHROPIC_BASE_URL"),apiKey:t=pt("ANTHROPIC_API_KEY")??null,authToken:r=pt("ANTHROPIC_AUTH_TOKEN")??null,...s}={}){Ar.add(this);Wt.set(this,void 0);const o={apiKey:t,authToken:r,...s,baseURL:e||`https://api.anthropic.com`};if(!o.dangerouslyAllowBrowser&&Xr()){throw new g("It looks like you're running in a browser-like environment.\n\nThis is disabled by default, as it risks exposing your secret API credentials to attackers.\nIf you understand the risks and have appropriate mitigations in place,\nyou can set the `dangerouslyAllowBrowser` option to `true`, e.g.,\n\nnew Anthropic({ apiKey, dangerouslyAllowBrowser: true });\n")}this.baseURL=o.baseURL;this.timeout=o.timeout??Pr.DEFAULT_TIMEOUT;this.logger=o.logger??console;const a="warn";this.logLevel=a;this.logLevel=sr(o.logLevel,"ClientOptions.logLevel",this)??sr(pt("ANTHROPIC_LOG"),"process.env['ANTHROPIC_LOG']",this)??a;this.fetchOptions=o.fetchOptions;this.maxRetries=o.maxRetries??2;this.fetch=o.fetch??Gr();p(this,Wt,Qr,"f");this._options=o;this.apiKey=typeof t==="string"?t:null;this.authToken=r}withOptions(e){const t=new this.constructor({...this._options,baseURL:this.baseURL,maxRetries:this.maxRetries,timeout:this.timeout,logger:this.logger,logLevel:this.logLevel,fetch:this.fetch,fetchOptions:this.fetchOptions,apiKey:this.apiKey,authToken:this.authToken,...e});return t}defaultQuery(){return this._options.defaultQuery}validateHeaders({values:e,nulls:t}){if(e.get("x-api-key")||e.get("authorization")){return}if(this.apiKey&&e.get("x-api-key")){return}if(t.has("x-api-key")){return}if(this.authToken&&e.get("authorization")){return}if(t.has("authorization")){return}throw new Error('Could not resolve authentication method. Expected either apiKey or authToken to be set. Or for one of the "X-Api-Key" or "Authorization" headers to be explicitly omitted')}async authHeaders(e){return u([await this.apiKeyAuth(e),await this.bearerAuth(e)])}async apiKeyAuth(e){if(this.apiKey==null){return void 0}return u([{"X-Api-Key":this.apiKey}])}async bearerAuth(e){if(this.authToken==null){return void 0}return u([{Authorization:`Bearer ${this.authToken}`}])}stringifyQuery(e){return Yr(e)}getUserAgent(){return`${this.constructor.name}/JS ${z}`}defaultIdempotencyKey(){return`stainless-node-retry-${Qt()}`}makeStatusError(e,t,r,s){return R.generate(e,t,r,s)}buildURL(e,t,r){const s=!i(this,Ar,"m",Ms).call(this)&&r||this.baseURL;const o=qr(e)?new URL(e):new URL(s+(s.endsWith("/")&&e.startsWith("/")?e.slice(1):e));const a=this.defaultQuery();const c=Object.fromEntries(o.searchParams);if(!er(a)||!er(c)){t={...c,...a,...t}}if(typeof t==="object"&&t&&!Array.isArray(t)){o.search=this.stringifyQuery(t)}return o.toString()}_calculateNonstreamingTimeout(e){const t=10*60;const r=60*60*e/128e3;if(r>t){throw new g("Streaming is required for operations that may take longer than 10 minutes. See https://github.com/anthropics/anthropic-sdk-typescript#streaming-responses for more details")}return t*1e3}async prepareOptions(e){}async prepareRequest(e,{url:t,options:r}){}get(e,t){return this.methodRequest("get",e,t)}post(e,t){return this.methodRequest("post",e,t)}patch(e,t){return this.methodRequest("patch",e,t)}put(e,t){return this.methodRequest("put",e,t)}delete(e,t){return this.methodRequest("delete",e,t)}methodRequest(e,t,r){return this.request(Promise.resolve(r).then(s=>{return{method:e,path:t,...s}}))}request(e,t=null){return new se(this,this.makeRequest(e,t,void 0))}async makeRequest(e,t,r){const s=await e;const o=s.maxRetries??this.maxRetries;if(t==null){t=o}await this.prepareOptions(s);const{req:a,url:c,timeout:l}=await this.buildRequest(s,{retryCount:o-t});await this.prepareRequest(a,{url:c,options:s});const h="log_"+(Math.random()*(1<<24)|0).toString(16).padStart(6,"0");const f=r===void 0?"":`, retryOf: ${r}`;const m=Date.now();M(this).debug(`[${h}] sending request`,W({retryOfRequestLogID:r,method:s.method,url:c,options:s,headers:a.headers}));if(s.signal?.aborted){throw new T}const x=new AbortController;const _=await this.fetchWithTimeout(c,a,l,x).catch(We);const E=Date.now();if(_ instanceof globalThis.Error){const w=`retrying, ${t} attempts remaining`;if(s.signal?.aborted){throw new T}const A=H(_)||/timed? ?out/i.test(String(_)+("cause"in _?String(_.cause):""));if(t){M(this).info(`[${h}] connection ${A?"timed out":"failed"} - ${w}`);M(this).debug(`[${h}] connection ${A?"timed out":"failed"} (${w})`,W({retryOfRequestLogID:r,url:c,durationMs:E-m,message:_.message}));return this.retryRequest(s,t,r??h)}M(this).info(`[${h}] connection ${A?"timed out":"failed"} - error; no more retries left`);M(this).debug(`[${h}] connection ${A?"timed out":"failed"} (error; no more retries left)`,W({retryOfRequestLogID:r,url:c,durationMs:E-m,message:_.message}));if(A){throw new fe}throw new G({cause:_})}const b=[..._.headers.entries()].filter(([w])=>w==="request-id").map(([w,A])=>", "+w+": "+JSON.stringify(A)).join("");const S=`[${h}${f}${b}] ${a.method} ${c} ${_.ok?"succeeded":"failed"} with status ${_.status} in ${E-m}ms`;if(!_.ok){const w=await this.shouldRetry(_);if(t&&w){const mt=`retrying, ${t} attempts remaining`;await zr(_.body);M(this).info(`${S} - ${mt}`);M(this).debug(`[${h}] response error (${mt})`,W({retryOfRequestLogID:r,url:_.url,status:_.status,headers:_.headers,durationMs:E-m}));return this.retryRequest(s,t,r??h,_.headers)}const A=w?`error; no more retries left`:`error; not retryable`;M(this).info(`${S} - ${A}`);const De=await _.text().catch(mt=>We(mt).message);const ft=_t(De);const Rr=ft?void 0:De;M(this).debug(`[${h}] response error (${A})`,W({retryOfRequestLogID:r,url:_.url,status:_.status,headers:_.headers,message:Rr,durationMs:Date.now()-m}));const Fs=this.makeStatusError(_.status,ft,Rr,_.headers);throw Fs}M(this).info(S);M(this).debug(`[${h}] response start`,W({retryOfRequestLogID:r,url:_.url,status:_.status,headers:_.headers,durationMs:E-m}));return{response:_,options:s,controller:x,requestLogID:h,retryOfRequestLogID:r,startTime:m}}getAPIList(e,t,r){return this.requestAPIList(t,r&&"then"in r?r.then(s=>({method:"get",path:e,...s})):{method:"get",path:e,...r})}requestAPIList(e,t){const r=this.makeRequest(t,null,void 0);return new ze(this,r,e)}async fetchWithTimeout(e,t,r,s){const{signal:o,method:a,...c}=t||{};const l=this._makeAbort(s);if(o)o.addEventListener("abort",l,{once:true});const h=setTimeout(l,r);const f=globalThis.ReadableStream&&c.body instanceof globalThis.ReadableStream||typeof c.body==="object"&&c.body!==null&&Symbol.asyncIterator in c.body;const m={signal:s.signal,...f?{duplex:"half"}:{},method:"GET",...c};if(a){m.method=a.toUpperCase()}try{return await this.fetch.call(void 0,e,m)}finally{clearTimeout(h)}}async shouldRetry(e){const t=e.headers.get("x-should-retry");if(t==="true")return true;if(t==="false")return false;if(e.status===408)return true;if(e.status===409)return true;if(e.status===429)return true;if(e.status>=500)return true;return false}async retryRequest(e,t,r,s){let o;const a=s?.get("retry-after-ms");if(a){const l=parseFloat(a);if(!Number.isNaN(l)){o=l}}const c=s?.get("retry-after");if(c&&!o){const l=parseFloat(c);if(!Number.isNaN(l)){o=l*1e3}else{o=Date.parse(c)-Date.now()}}if(o===void 0){const l=e.maxRetries??this.maxRetries;o=this.calculateDefaultRetryTimeoutMillis(t,l)}await Dr(o);return this.makeRequest(e,t-1,r)}calculateDefaultRetryTimeoutMillis(e,t){const r=.5;const s=8;const o=t-e;const a=Math.min(r*Math.pow(2,o),s);const c=1-Math.random()*.25;return a*c*1e3}calculateNonstreamingTimeout(e,t){const r=60*60*1e3;const s=60*10*1e3;const o=r*e/128e3;if(o>s||t!=null&&e>t){throw new g("Streaming is required for operations that may take longer than 10 minutes. See https://github.com/anthropics/anthropic-sdk-typescript#long-requests for more details")}return s}async buildRequest(e,{retryCount:t=0}={}){const r={...e};const{method:s,path:o,query:a,defaultBaseURL:c}=r;const l=this.buildURL(o,a,c);if("timeout"in r)Hr("timeout",r.timeout);r.timeout=r.timeout??this.timeout;const{bodyHeaders:h,body:f}=this.buildBody({options:r});const m=await this.buildHeaders({options:e,method:s,bodyHeaders:h,retryCount:t});const x={method:s,headers:m,...r.signal&&{signal:r.signal},...globalThis.ReadableStream&&f instanceof globalThis.ReadableStream&&{duplex:"half"},...f&&{body:f},...this.fetchOptions??{},...r.fetchOptions??{}};return{req:x,url:l,timeout:r.timeout}}async buildHeaders({options:e,method:t,bodyHeaders:r,retryCount:s}){let o={};if(this.idempotencyHeader&&t!=="get"){if(!e.idempotencyKey)e.idempotencyKey=this.defaultIdempotencyKey();o[this.idempotencyHeader]=e.idempotencyKey}const a=u([o,{Accept:"application/json","User-Agent":this.getUserAgent(),"X-Stainless-Retry-Count":String(s),...e.timeout?{"X-Stainless-Timeout":String(Math.trunc(e.timeout/1e3))}:{},...Kr(),...this._options.dangerouslyAllowBrowser?{"anthropic-dangerous-direct-browser-access":"true"}:void 0,"anthropic-version":"2023-06-01"},await this.authHeaders(e),this._options.defaultHeaders,r,e.headers]);this.validateHeaders(a);return a.values}_makeAbort(e){return()=>e.abort()}buildBody({options:{body:e,headers:t}}){if(!e){return{bodyHeaders:void 0,body:void 0}}const r=u([t]);if(ArrayBuffer.isView(e)||e instanceof ArrayBuffer||e instanceof DataView||typeof e==="string"&&r.values.has("content-type")||globalThis.Blob&&e instanceof globalThis.Blob||e instanceof FormData||e instanceof URLSearchParams||globalThis.ReadableStream&&e instanceof globalThis.ReadableStream){return{bodyHeaders:void 0,body:e}}else if(typeof e==="object"&&(Symbol.asyncIterator in e||Symbol.iterator in e&&"next"in e&&typeof e.next==="function")){return{bodyHeaders:void 0,body:bt(e)}}else if(typeof e==="object"&&r.values.get("content-type")==="application/x-www-form-urlencoded"){return{bodyHeaders:{"content-type":"application/x-www-form-urlencoded"},body:this.stringifyQuery(e)}}else{return i(this,Wt,"f").call(this,{body:e,headers:r})}}};Pr=v,Wt=new WeakMap,Ar=new WeakSet,Ms=function n(){return this.baseURL!=="https://api.anthropic.com"};v.Anthropic=Pr;v.HUMAN_PROMPT=Ts;v.AI_PROMPT=Is;v.DEFAULT_TIMEOUT=6e5;v.AnthropicError=g;v.APIError=R;v.APIConnectionError=G;v.APIConnectionTimeoutError=fe;v.APIUserAbortError=T;v.NotFoundError=be;v.ConflictError=ye;v.RateLimitError=xe;v.BadRequestError=me;v.AuthenticationError=ge;v.InternalServerError=Se;v.PermissionDeniedError=_e;v.UnprocessableEntityError=we;v.toFile=vt;var L=class extends v{constructor(){super(...arguments);this.completions=new he(this);this.messages=new re(this);this.models=new pe(this);this.beta=new I(this)}};L.Completions=he;L.Messages=re;L.Models=pe;L.Beta=I;function Os(n){if(n){return n}if(typeof process!=="undefined"&&process.env.PI_CACHE_RETENTION==="long"){return"long"}return"short"}function Ln(n,e){const t=Os(e);if(t==="none"){return{retention:t}}const r=t==="long"&&Kt(n).supportsLongCacheRetention?"1h":void 0;return{retention:t,cacheControl:{type:"ephemeral",...r&&{ttl:r}}}}var Nn="2.1.75";var Fn=["Read","Write","Edit","Bash","Grep","Glob","AskUserQuestion","EnterPlanMode","ExitPlanMode","KillShell","NotebookEdit","Skill","Task","TaskOutput","TodoWrite","WebFetch","WebSearch"];var jn=new Map(Fn.map(n=>[n.toLowerCase(),n]));var Bs=n=>jn.get(n.toLowerCase())??n;var qn=(n,e)=>{if(e&&e.length>0){const t=n.toLowerCase();const r=e.find(s=>s.name.toLowerCase()===t);if(r)return r.name}return n};function Cs(n){const e=n.some(s=>s.type==="image");if(!e){return q(n.map(s=>s.text).join("\n"))}const t=n.map(s=>{if(s.type==="text"){return{type:"text",text:q(s.text)}}return{type:"image",source:{type:"base64",media_type:s.mimeType,data:s.data}}});const r=t.some(s=>s.type==="text");if(!r){t.unshift({type:"text",text:"(see attached image)"})}return t}var Un=["claude-opus-5","claude-sonnet-5","claude-fable-5","claude-mythos-5","claude-mythos-preview"];function Ls(n){if(typeof n!=="string")return false;const e=n.trim().toLowerCase();const t=e.replace(/\[1m\]$/u,"");return Un.includes(t)}var Hn="fine-grained-tool-streaming-2025-05-14";var Dn="interleaved-thinking-2025-05-14";function Kt(n){const e=n.provider==="fireworks";const t=n.provider==="cloudflare-ai-gateway"&&n.baseUrl.includes("anthropic");return{supportsEagerToolInputStreaming:n.compat?.supportsEagerToolInputStreaming??!e,supportsLongCacheRetention:n.compat?.supportsLongCacheRetention??!e,sendSessionAffinityHeaders:n.compat?.sendSessionAffinityHeaders??!!(e||t),supportsCacheControlOnTools:n.compat?.supportsCacheControlOnTools??!e,supportsTemperature:n.compat?.supportsTemperature??true,allowEmptySignature:n.compat?.allowEmptySignature??false}}function Jt(...n){const e={};for(const t of n){if(t){Object.assign(e,t)}}return e}var Wn=new Set(["message_start","message_delta","message_stop","content_block_start","content_block_delta","content_block_stop"]);function Ns(n){if(!n.event&&n.data.length===0){return null}const e={event:n.event,data:n.data.join("\n"),raw:[...n.raw]};n.event=null;n.data=[];n.raw=[];return e}function Er(n,e){if(n===""){return Ns(e)}e.raw.push(n);if(n.startsWith(":")){return null}const t=n.indexOf(":");const r=t===-1?n:n.slice(0,t);let s=t===-1?"":n.slice(t+1);if(s.startsWith(" ")){s=s.slice(1)}if(r==="event"){e.event=s}else if(r==="data"){e.data.push(s)}return null}function Jn(n){const e=n.indexOf("\r");const t=n.indexOf("\n");if(e===-1){return t}if(t===-1){return e}return Math.min(e,t)}function Vt(n){const e=Jn(n);if(e===-1){return null}let t=e+1;if(n[e]==="\r"&&n[t]==="\n"){t+=1}return{line:n.slice(0,e),rest:n.slice(t)}}async function*Vn(n,e){const t=n.getReader();const r=new TextDecoder;const s={event:null,data:[],raw:[]};let o="";const a=()=>{void t.cancel(e?.reason).catch(()=>{})};e?.addEventListener("abort",a,{once:true});if(e?.aborted)a();try{while(true){if(e?.aborted){throw new Error("Request was aborted")}const{value:h,done:f}=await t.read();if(e?.aborted){throw new Error("Request was aborted")}if(f){break}o+=r.decode(h,{stream:true});let m=Vt(o);while(m){o=m.rest;const x=Er(m.line,s);if(x){yield x}m=Vt(o)}}o+=r.decode();let c=Vt(o);while(c){o=c.rest;const h=Er(c.line,s);if(h){yield h}c=Vt(o)}if(o.length>0){const h=Er(o,s);if(h){yield h}}const l=Ns(s);if(l){yield l}}finally{e?.removeEventListener("abort",a);t.releaseLock()}}async function*Xn(n,e){if(!n.body){throw new Error("Attempted to iterate over an Anthropic response with no body")}let t=false;let r=false;let s=false;const o=Date.now();let a=0;let c=0;let l=0;let h=null;let f=null;for await(const m of Vn(n.body,e)){a+=1;const x=Date.now()-o;h??=x;f=x;if(m.event==="error"){throw new Error(m.data)}if(!Wn.has(m.event??"")){continue}try{const _=Ir(m.data);c+=1;if(_.type==="message_start"){t=true}else if(_.type==="message_stop"){r=true}else if(_.type==="message_delta"){l+=1;const E=_.delta?.stop_reason;if(typeof E==="string"&&E.length>0){s=true}}yield _}catch(_){const E=_ instanceof Error?_.message:String(_);throw new Error(`Could not parse Anthropic SSE event ${m.event}: ${E}; data=${m.data}; raw=${m.raw.join("\\n")}`)}}if(e?.aborted){return}if(!t){const m=`rawEventCount=${a}; messageEventCount=${c}; firstEventAtMs=${h??"none"}; lastEventAtMs=${f??"none"}; eofAtMs=${Date.now()-o}`;throw new Error(r?`Anthropic stream ended without message_start (${m})`:`Anthropic stream ended without any message events (${m})`)}if(t&&!r){throw new Error("Anthropic stream ended before message_stop")}if(t&&r&&!s){const m=`messageDeltaCount=${l}; rawEventCount=${a}; messageEventCount=${c}; lastEventAtMs=${f??"none"}; eofAtMs=${Date.now()-o}`;throw new Error(`Anthropic stream ended without stop_reason (${m})`)}}var Xt=(n,e,t)=>{const r=new Tr;(async()=>{const s={role:"assistant",content:[],api:n.api,provider:n.provider,model:n.id,usage:{input:0,output:0,cacheRead:0,cacheWrite:0,totalTokens:0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},stopReason:"stop",timestamp:Date.now()};let o;try{let a;let c;if(t?.client){a=t.client;c=false}else{const b=t?.apiKey;if(!b){throw new Error(`No API key for provider: ${n.provider}`)}let S;if(n.provider==="github-copilot"){const ft=Br(e.messages);S=Lr({messages:e.messages,hasImages:ft})}const w=t?.cacheRetention??Os();const A=w==="none"?void 0:t?.sessionId;const De=Gn(n,b,t?.interleavedThinking??true,Zn(n,e),t?.headers,S,A,t?.fetch);a=De.client;c=De.isOAuthToken}let l=zn(n,e,c,t);const h=await t?.onPayload?.(l,n);if(h!==void 0){l=h}const f={...t?.signal?{signal:t.signal}:{},...t?.timeoutMs!==void 0?{timeout:t.timeoutMs}:{},maxRetries:t?.maxRetries??0};const m=await a.messages.create({...l,stream:true},f).asResponse();await t?.onResponse?.({status:m.status,headers:Mr(m.headers)},n);r.push({type:"start",partial:s});const x=s.content;const _=Xn(m,t?.signal);const E=$r(_,t?.onProviderStreamEvent,n);for await(const b of E){if(b.type==="message_start"){s.responseId=b.message.id;s.usage.input=b.message.usage.input_tokens||0;s.usage.output=b.message.usage.output_tokens||0;s.usage.cacheRead=b.message.usage.cache_read_input_tokens||0;s.usage.cacheWrite=b.message.usage.cache_creation_input_tokens||0;s.usage.totalTokens=s.usage.input+s.usage.output+s.usage.cacheRead+s.usage.cacheWrite;Gt(n,s.usage)}else if(b.type==="content_block_start"){if(b.content_block.type==="text"){const S={type:"text",text:"",index:b.index};s.content.push(S);r.push({type:"text_start",contentIndex:s.content.length-1,partial:s})}else if(b.content_block.type==="thinking"){const S={type:"thinking",thinking:"",thinkingSignature:"",index:b.index};s.content.push(S);r.push({type:"thinking_start",contentIndex:s.content.length-1,partial:s})}else if(b.content_block.type==="redacted_thinking"){const S={type:"thinking",thinking:"[Reasoning redacted]",thinkingSignature:b.content_block.data,redacted:true,index:b.index};s.content.push(S);r.push({type:"thinking_start",contentIndex:s.content.length-1,partial:s})}else if(b.content_block.type==="tool_use"){const S={type:"toolCall",id:b.content_block.id,name:c?qn(b.content_block.name,e.tools):b.content_block.name,arguments:b.content_block.input??{},partialJson:"",index:b.index};s.content.push(S);r.push({type:"toolcall_start",contentIndex:s.content.length-1,partial:s})}}else if(b.type==="content_block_delta"){if(b.delta.type==="text_delta"){const S=x.findIndex(A=>A.index===b.index);const w=x[S];if(w&&w.type==="text"){w.text+=b.delta.text;r.push({type:"text_delta",contentIndex:S,delta:b.delta.text,partial:s})}}else if(b.delta.type==="thinking_delta"){const S=x.findIndex(A=>A.index===b.index);const w=x[S];if(w&&w.type==="thinking"){w.thinking+=b.delta.thinking;r.push({type:"thinking_delta",contentIndex:S,delta:b.delta.thinking,partial:s})}}else if(b.delta.type==="input_json_delta"){const S=x.findIndex(A=>A.index===b.index);const w=x[S];if(w&&w.type==="toolCall"){w.partialJson+=b.delta.partial_json;w.arguments=zt(w.partialJson);r.push({type:"toolcall_delta",contentIndex:S,delta:b.delta.partial_json,partial:s})}}else if(b.delta.type==="signature_delta"){const S=x.findIndex(A=>A.index===b.index);const w=x[S];if(w&&w.type==="thinking"){w.thinkingSignature=w.thinkingSignature||"";w.thinkingSignature+=b.delta.signature}}}else if(b.type==="content_block_stop"){const S=x.findIndex(A=>A.index===b.index);const w=x[S];if(w){delete w.index;if(w.type==="text"){r.push({type:"text_end",contentIndex:S,content:w.text,partial:s})}else if(w.type==="thinking"){r.push({type:"thinking_end",contentIndex:S,content:w.thinking,partial:s})}else if(w.type==="toolCall"){w.arguments=zt(w.partialJson);delete w.partialJson;r.push({type:"toolcall_end",contentIndex:S,toolCall:w,partial:s})}}}else if(b.type==="message_delta"){if(b.delta.stop_reason){s.stopReason=so(b.delta.stop_reason);if(b.delta.stop_reason==="refusal"){o=to(b.delta)}}if(b.usage.input_tokens!=null){s.usage.input=b.usage.input_tokens}if(b.usage.output_tokens!=null){s.usage.output=b.usage.output_tokens}if(b.usage.cache_read_input_tokens!=null){s.usage.cacheRead=b.usage.cache_read_input_tokens}if(b.usage.cache_creation_input_tokens!=null){s.usage.cacheWrite=b.usage.cache_creation_input_tokens}s.usage.totalTokens=s.usage.input+s.usage.output+s.usage.cacheRead+s.usage.cacheWrite;Gt(n,s.usage)}}if(t?.signal?.aborted){throw new Error("Request was aborted")}if(o){throw new Error(ro(o))}if(s.stopReason==="aborted"||s.stopReason==="error"){throw new Error("An unknown error occurred")}r.push({type:"done",reason:s.stopReason,message:s});r.end()}catch(a){Cr(t?.onProviderError,a,n);for(const c of s.content){delete c.index;delete c.partialJson}s.stopReason=t?.signal?.aborted?"aborted":"error";s.errorMessage=a instanceof Error?a.message:JSON.stringify(a);r.push({type:"error",reason:s.stopReason,error:s});r.end()}})();return r};function $s(n,e){const t=e?n.thinkingLevelMap?.[e]:void 0;if(typeof t==="string")return t;switch(e){case"minimal":case"low":return"low";case"medium":return"medium";case"high":return"high";default:return"high"}}var Kl=(n,e,t)=>{const r=t?.apiKey;if(!r){throw new Error(`No API key for provider: ${n.provider}`)}const s=Nr(n,t,r);if(!t?.reasoning){return Xt(n,e,{...s,thinkingEnabled:false})}if(Ls(n.id)){const a=$s(n,t.reasoning);return Xt(n,e,{...s,thinkingEnabled:true,effort:a})}if(n.compat?.forceAdaptiveThinking===true){const a=$s(n,t.reasoning);return Xt(n,e,{...s,thinkingEnabled:true,effort:a})}const o=Fr(s.maxTokens,n.maxTokens,t.reasoning,t.thinkingBudgets);return Xt(n,e,{...s,maxTokens:o.maxTokens,thinkingEnabled:true,thinkingBudgetTokens:o.thinkingBudget})};function Kn(n){return n.includes("sk-ant-oat")}function Gn(n,e,t,r,s,o,a,c){const l=t&&n.compat?.forceAdaptiveThinking!==true;const h=[];if(r){h.push(Hn)}if(l){h.push(Dn)}const f=c?{fetch:c}:{};if(n.provider==="cloudflare-ai-gateway"){const _=new L({apiKey:null,authToken:null,baseURL:Or(n),dangerouslyAllowBrowser:true,...f,defaultHeaders:Jt({accept:"application/json","anthropic-dangerous-direct-browser-access":"true","cf-aig-authorization":`Bearer ${e}`,"x-api-key":null,Authorization:null,...h.length>0?{"anthropic-beta":h.join(",")}:{}},n.headers,s)});return{client:_,isOAuthToken:false}}if(n.provider==="github-copilot"){const _=new L({apiKey:null,authToken:e,baseURL:n.baseUrl,dangerouslyAllowBrowser:true,...f,defaultHeaders:Jt({accept:"application/json","anthropic-dangerous-direct-browser-access":"true",...h.length>0?{"anthropic-beta":h.join(",")}:{}},n.headers,o,s)});return{client:_,isOAuthToken:false}}if(Kn(e)){const _=new L({apiKey:null,authToken:e,baseURL:n.baseUrl,dangerouslyAllowBrowser:true,...f,defaultHeaders:Jt({accept:"application/json","anthropic-dangerous-direct-browser-access":"true","anthropic-beta":["claude-code-20250219","oauth-2025-04-20",...h].join(","),"user-agent":`claude-cli/${Nn}`,"x-app":"cli"},n.headers,s)});return{client:_,isOAuthToken:true}}const m=a&&Kt(n).sendSessionAffinityHeaders?{"x-session-affinity":a}:{};const x=new L({apiKey:e,authToken:null,baseURL:n.baseUrl,dangerouslyAllowBrowser:true,...f,defaultHeaders:Jt({accept:"application/json","anthropic-dangerous-direct-browser-access":"true",...h.length>0?{"anthropic-beta":h.join(",")}:{}},m,n.headers,s)});return{client:x,isOAuthToken:false}}function zn(n,e,t,r){const{cacheControl:s}=Ln(n,r?.cacheRetention);const o=Kt(n);const a={model:n.id,messages:Yn(e.messages,n,t,s,o.allowEmptySignature),max_tokens:r?.maxTokens??n.maxTokens,stream:true};if(t){a.system=[{type:"text",text:"You are Claude Code, Anthropic's official CLI for Claude.",...s?{cache_control:s}:{}}];if(e.systemPrompt){a.system.push({type:"text",text:q(e.systemPrompt),...s?{cache_control:s}:{}})}}else if(e.systemPrompt){a.system=[{type:"text",text:q(e.systemPrompt),...s?{cache_control:s}:{}}]}if(r?.temperature!==void 0&&!r?.thinkingEnabled&&o.supportsTemperature){a.temperature=r.temperature}if(e.tools&&e.tools.length>0){a.tools=eo(e.tools,t,o.supportsEagerToolInputStreaming,o.supportsCacheControlOnTools?s:void 0)}if(n.reasoning){if(r?.thinkingEnabled){const c=r.thinkingDisplay??"summarized";if(Ls(n.id)){if(r.effort){a.output_config={effort:r.effort}}}else if(n.compat?.forceAdaptiveThinking===true){a.thinking={type:"adaptive",display:c};if(r.effort){a.output_config=r.effort==="xhigh"?{effort:r.effort}:{effort:r.effort}}}else{a.thinking={type:"enabled",budget_tokens:r.thinkingBudgetTokens||1024,display:c}}}else if(r?.thinkingEnabled===false){a.thinking={type:"disabled"}}}if(r?.metadata){const c=r.metadata.user_id;if(typeof c==="string"){a.metadata={user_id:c}}}if(r?.toolChoice){if(typeof r.toolChoice==="string"){a.tool_choice={type:r.toolChoice}}else{a.tool_choice=r.toolChoice}}return a}function Qn(n){return n.replace(/[^a-zA-Z0-9_-]/g,"_").slice(0,64)}function Yn(n,e,t,r,s=false){const o=[];const a=jr(n,e,Qn);for(let c=0;c<a.length;c++){const l=a[c];if(l.role==="user"){if(typeof l.content==="string"){if(l.content.trim().length>0){o.push({role:"user",content:q(l.content)})}}else{const h=l.content.map(m=>{if(m.type==="text"){return{type:"text",text:q(m.text)}}else{return{type:"image",source:{type:"base64",media_type:m.mimeType,data:m.data}}}});const f=h.filter(m=>{if(m.type==="text"){return m.text.trim().length>0}return true});if(f.length===0)continue;o.push({role:"user",content:f})}}else if(l.role==="assistant"){const h=[];for(const f of l.content){if(f.type==="text"){if(f.text.trim().length===0)continue;h.push({type:"text",text:q(f.text)})}else if(f.type==="thinking"){if(f.redacted){h.push({type:"redacted_thinking",data:f.thinkingSignature});continue}const m=f.thinkingSignature;const x=!!m&&m.trim().length>0;if(f.thinking.trim().length===0&&!x)continue;if(!x){h.push(s?{type:"thinking",thinking:q(f.thinking),signature:""}:{type:"text",text:q(f.thinking)})}else{h.push({type:"thinking",thinking:q(f.thinking),signature:m})}}else if(f.type==="toolCall"){h.push({type:"tool_use",id:f.id,name:t?Bs(f.name):f.name,input:f.arguments??{}})}}if(h.length===0)continue;o.push({role:"assistant",content:h})}else if(l.role==="toolResult"){const h=[];h.push({type:"tool_result",tool_use_id:l.toolCallId,content:Cs(l.content),is_error:l.isError});let f=c+1;while(f<a.length&&a[f].role==="toolResult"){const m=a[f];h.push({type:"tool_result",tool_use_id:m.toolCallId,content:Cs(m.content),is_error:m.isError});f++}c=f-1;o.push({role:"user",content:h})}}if(r&&o.length>0){const c=o[o.length-1];if(c.role==="user"){if(Array.isArray(c.content)){const l=c.content[c.content.length-1];if(l&&(l.type==="text"||l.type==="image"||l.type==="tool_result")){l.cache_control=r}}else if(typeof c.content==="string"){c.content=[{type:"text",text:c.content,cache_control:r}]}}}return o}function Zn(n,e){return!!e.tools?.length&&!Kt(n).supportsEagerToolInputStreaming}function eo(n,e,t,r){if(!n)return[];return n.map((s,o)=>{const a=s.parameters;return{name:e?Bs(s.name):s.name,description:s.description,...t?{eager_input_streaming:true}:{},input_schema:{type:"object",properties:a.properties??{},required:a.required??[]},...r&&o===n.length-1?{cache_control:r}:{}}})}function to(n){const e=n.stop_details;if(!e||typeof e!=="object")return{};const{category:t,explanation:r}=e;return{...typeof t==="string"&&t.trim()?{category:t.trim()}:{},...typeof r==="string"&&r.trim()?{explanation:r.trim()}:{}}}function ro(n){const e=n.category?`; category: ${n.category}`:"";const t=n.explanation?`: ${n.explanation}`:"";return`Model declined the request (stop_reason: refusal${e})${t}`}function so(n){switch(n){case"end_turn":return"stop";case"max_tokens":return"length";case"tool_use":return"toolUse";case"refusal":return"error";case"pause_turn":return"stop";case"stop_sequence":return"stop";case"sensitive":return"error";default:throw new Error(`Unhandled stop reason: ${n}`)}}export{Un as a,Ls as b,Xt as c,Kl as d};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { createRequire as __alran_cR } from "module"; import { basename as __alran_basename, dirname as __alran_dirname, join as __alran_join } from "path"; import { fileURLToPath as __alran_fileURLToPath, pathToFileURL as __alran_pathToFileURL } from "url"; const __alran_tuiCurrentModuleDir = __alran_dirname(__alran_fileURLToPath(import.meta.url)); const __alran_tuiPackageRoot = __alran_basename(__alran_tuiCurrentModuleDir) === "chunks" ? __alran_dirname(__alran_tuiCurrentModuleDir) : __alran_tuiCurrentModuleDir; const __alran_tuiPackageEntryUrl = __alran_pathToFileURL(__alran_join(__alran_tuiPackageRoot, "cli.js")).href; const require = __alran_cR(__alran_tuiPackageEntryUrl); const __dirname = __alran_tuiPackageRoot;
|
|
2
|
+
import{stripVTControlCharacters as f}from"node:util";var c=/[\u0000-\u0008\u000B\u000C\u000E-\u001F\u007F]/gu;function T(e,t){const i=[t.summary,t.nextStep,t.preservation].map(r=>r?.trim()).filter(r=>Boolean(r)).join(" ");const n=a(e);return{message:i,...n&&n!==i?{diagnostic:n}:{}}}function _(e,t){const i=t.summary.trim();const n=a(e);const r=n?`${i.replace(/[.:;!?]+$/u,"")}: ${n}`:i;return[r,t.nextStep,t.preservation].map(s=>s?.trim()).filter(s=>Boolean(s)).map(l).join(" ")}var d="output_limit_exhausted";var h="The model ran out of output space while still thinking and did not finish after several automatic retries.";function E(e){return e?.trim()===d}function a(e){if(e===void 0||e===null)return"";const t=e instanceof Error?e.message:String(e);return p(t).trim()}function p(e){return f(e).replace(c,"").replace(/-----BEGIN (?:[A-Z0-9 ]+ )?PRIVATE KEY-----[\s\S]*?-----END (?:[A-Z0-9 ]+ )?PRIVATE KEY-----/giu,"[redacted private key]").replace(/\bsk-[A-Za-z0-9._-]{8,}\b/gu,"sk-[redacted]").replace(/\b(?:sk|pk|ghp|github_pat|xox[baprs])[-_][A-Za-z0-9_-]{12,}\b/giu,"[redacted]").replace(/\beyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\b/gu,"[redacted]").replace(/\bBearer\s+[^\s,;]+/giu,"Bearer [redacted]").replace(/\b(Authorization)(\s*[:=]\s*)((?:Bearer|Basic|Token)\s+)?(?:"[^"]*"|'[^']*'|[^\s,;]+)/giu,"$1$2$3[redacted]").replace(/\b(api[-_ ]?key|access[-_ ]?token|refresh[-_ ]?token|token|password|secret)(\s*[:=]\s*)(?:"[^"]*"|'[^']*'|[^\s,;]+)/giu,"$1$2[redacted]")}function l(e){return/[.!?…]$/u.test(e)?e:`${e}.`}function u(e){if(!e?.length)return[];return Array.from(new Set(e.map(t=>t.trim()).filter(t=>t.length>0)))}function x(e){return u(e?.effortOptions).length>0}var g="thinking";function k(e,t){const i=e?.variant;if(e?.thinkingConfig?.mode==="forced_off"||i===""||i==="none-thinking")return void 0;const n=u(e?.effortOptions);const r=e?.defaultEffort?.trim();const s=n.length>0?n:r?[r]:[];const o=(t??(e?.selected?e.thinking?.effort:void 0))?.trim();if(o&&s.includes(o))return o;if(i!==void 0&&i!==g)return void 0;if(r&&s.includes(r))return r;return n[Math.floor(n.length/2)]}export{u as a,x as b,k as c,T as d,_ as e,h as f,E as g,a as h,p as i};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { createRequire as __alran_cR } from "module"; import { basename as __alran_basename, dirname as __alran_dirname, join as __alran_join } from "path"; import { fileURLToPath as __alran_fileURLToPath, pathToFileURL as __alran_pathToFileURL } from "url"; const __alran_tuiCurrentModuleDir = __alran_dirname(__alran_fileURLToPath(import.meta.url)); const __alran_tuiPackageRoot = __alran_basename(__alran_tuiCurrentModuleDir) === "chunks" ? __alran_dirname(__alran_tuiCurrentModuleDir) : __alran_tuiCurrentModuleDir; const __alran_tuiPackageEntryUrl = __alran_pathToFileURL(__alran_join(__alran_tuiPackageRoot, "cli.js")).href; const require = __alran_cR(__alran_tuiPackageEntryUrl); const __dirname = __alran_tuiPackageRoot;
|
|
2
|
+
var r=class extends Error{constructor(n="Alran update cancelled; the previous installation remains active."){super(n);this.name="AlranUpdateCancelledError"}};var a=class extends Error{constructor(n){super(n);this.name="AlranUpdateAdmissionError"}};function o(e){if(e?.aborted)throw new r}function i(e,n,t){try{e.onPhase?.({phase:n,cancellable:t})}catch{}}function l(e){return e instanceof r}function s(e){return e instanceof a}export{r as a,a as b,o as c,i as d,l as e,s as f};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { createRequire as __alran_cR } from "module"; import { basename as __alran_basename, dirname as __alran_dirname, join as __alran_join } from "path"; import { fileURLToPath as __alran_fileURLToPath, pathToFileURL as __alran_pathToFileURL } from "url"; const __alran_tuiCurrentModuleDir = __alran_dirname(__alran_fileURLToPath(import.meta.url)); const __alran_tuiPackageRoot = __alran_basename(__alran_tuiCurrentModuleDir) === "chunks" ? __alran_dirname(__alran_tuiCurrentModuleDir) : __alran_tuiCurrentModuleDir; const __alran_tuiPackageEntryUrl = __alran_pathToFileURL(__alran_join(__alran_tuiPackageRoot, "cli.js")).href; const require = __alran_cR(__alran_tuiPackageEntryUrl); const __dirname = __alran_tuiPackageRoot;
|
|
2
|
+
import{q as D}from"./chunk-2TF6JAQM.js";import{a as p}from"./chunk-AGUSPIUP.js";var h=["totalTokens","inputTokens","outputTokens","reasoningTokens","cacheReadTokens","cacheWriteTokens"];function E(e,t){return e.role==="assistant"&&(e.turnId===void 0||e.turnId===t)&&e.kind?.startsWith("compaction")===true}function Q(e,t){if(e.role!=="assistant"||e.turnId!==void 0&&e.turnId!==t||E(e,t))return void 0;const i=Object.fromEntries(h.flatMap(r=>T(e.usage?.[r])?[[r,e.usage?.[r]]]:[]));const n=h.some(r=>e.usage?.[r]!==void 0&&!T(e.usage?.[r]));return{...e.id?.trim()?{messageId:e.id}:{},...Object.keys(i).length?{usage:i}:{},...n?{usageIncomplete:true}:{}}}function F(e,t){const i=t.messageId?e.findIndex(r=>r.messageId===t.messageId):-1;const n=e[i];if(!n){e.push(t);return}e[i]={...n,...t,...n.usage||t.usage?{usage:{...n.usage,...t.usage}}:{}}}function j(e){let t=e.length===0||e.some(n=>!T(n.usage?.inputTokens)||!T(n.usage?.outputTokens)||n.usageIncomplete);const i=Object.fromEntries(h.flatMap(n=>{const r=e.map(u=>u.usage?.[n]).filter(T);if(!r.length)return[];const o=r.reduce((u,d)=>u+d,0);if(!Number.isFinite(o)){t=true;return[]}return[[n,o]]}));return{...Object.keys(i).length?{usage:i}:{},usageIncomplete:t}}function T(e){return typeof e==="number"&&Number.isFinite(e)&&e>=0}var Z=["compaction_start","compaction","compaction_failed","review_start","review_failed","review_aborted","review_interrupted"];var ee=new Set(Z);function B(e){return e!==void 0&&ee.has(e)}function G(e,t){const i=e.type==="message"?e.message.turnId:e.turnId;if(i&&i!==t)return false;const n=e.type==="message"?e.message.toolCalls:e.type==="delta"?e.toolCalls:void 0;return n?.some(r=>{if(r.error||r.status!==2&&r.status!=="2"&&r.status!=="finished")return false;if(!r.output||typeof r.output!=="object"||Array.isArray(r.output))return false;const o=r.output.details;return typeof o==="object"&&o!==null&&!Array.isArray(o)&&o.waiting_for_user===true})??false}async function K(e,t,i,n=D,r){const o=await e.getPendingQuestionnaire?.(n,t,r);return o?.requester?.sessionId===t&&o.requester.runId===i?o:void 0}var te=2147483647;var ne=1e3;var W=class{constructor(t,i={}){this.runtime=t;this.options=i;this.nowMs=i.nowMs??Date.now}runtime;options;activeRun;retiringRun;nowMs;activeTurnId(){return this.activeRun?.turnId}detachActiveRun(t){const i=this.activeRun;if(!i||t!==void 0&&i.turnId!==t)return false;this.activeRun=void 0;return true}retiringTurnId(){return this.retiringRun?.turnId}retirement(){return this.retiringRun?.settlement}async*sendWithQueueRecovery(t,i,n,r){const o=ie(t,i,r);let u=false;try{for await(const d of this.runtime.sendMessage(o,n)){u=true;yield d}}catch(d){if(u||r!==void 0||!(d instanceof p)||d.code!=="local_session_queue_paused"||!t.onQueuePaused||n.aborted)throw d;const c=await t.onQueuePaused(i.sessionId,n);n.throwIfAborted();if(c==="cancel")throw new p("cancelled","The draft was kept.",{code:"PAUSED_QUEUE_SEND_CANCELLED"});yield*this.runtime.sendMessage(o,n,{pausedQueueAction:c==="paused-queue-clear"?"clear":"keep"})}}async execute(t,i=()=>void 0,n,r){if(this.activeRun)throw new Error("A run is already active.");if(this.retiringRun)throw new Error("The previous run is still stopping.");const o=de(t.turnId);this.activeRun=o;const u=this.nowMs();let d;let c;let w=false;let a="succeeded";let f=null;let g="";let l;let P=0;const y=[];let _=false;let x=false;const M=this.options.releaseObserverOnStop===true;let R=Promise.resolve();const C=m=>{if(!M)return z(i,m);R=R.then(()=>z(i,m));return ce(R,o.controller.signal)};try{c=await le(t.session,o.controller.signal);if(!c){throw o.controller.signal.reason??new Error("Turn cancelled before Session setup.")}o.sessionId=c.sessionId;let m;if(t.policy?.timeoutMs!==void 0){m=this.nowMs()+t.policy.timeoutMs;d=me(()=>{void this.stopActive(o,"timeout").catch(()=>void 0)},t.policy.timeoutMs)}const k=this.sendWithQueueRecovery(t,c,o.controller.signal,m)[Symbol.asyncIterator]();try{while(true){const O=await k.next();if(O.done)break;const s=O.value;x||=G(s,t.turnId);if(!w){w=true;n?.()}const U=se(s);if(U){a="awaiting-user-continuation";l=U;await C(s);break}if(q(s)&&B(s.message.kind)){_||=E(s.message,t.turnId)}else if(q(s)){const N=Q(s.message,t.turnId);if(N)F(y,N);if(t.policy?.maxSteps!==void 0&&P>=t.policy.maxSteps){a="limit_exceeded";await this.stopActive(o,"limit");break}P+=1;if(s.message.toolCalls?.length){this.reportAnswerSelection({kind:"answer_excluded",messageId:s.message.id,reason:"tool_calls"});f=null;g=""}else{const A=s.message.content?.trim()?s.message.content:g;f=A.trim()?A:null;this.reportAnswerSelection({kind:"answer_selected",messageId:s.message.id,answerSource:s.message.content?.trim()?"completed_message":"completed_message_draft",answerBytes:Buffer.byteLength(A),finishReason:s.message.finishReason});g=""}}else if(re(s)){g+=s.content}const b=ue(s);if(b){a=b.status;l=b.error}await C(s)}}finally{await k.return?.(void 0)}if(g.trim()){this.reportAnswerSelection({kind:"answer_selected",answerSource:"trailing_draft",answerBytes:Buffer.byteLength(g),replacedAnswer:f!==null});f=g}if(a==="succeeded"&&!o.controller.signal.aborted&&(x||await K(this.runtime,c.sessionId,t.turnId,c.agentName,o.controller.signal))){a="awaiting-user-continuation";f=null;l=$()}if(t.policy?.requireAnswer===true&&a==="succeeded"&&f===null){a="failed";l={category:"runtime",code:"EMPTY_RESPONSE",message:"Runtime completed without a final assistant response.",retryable:true}}a=Y(o.stopReason,a)}catch(m){if(o.stopReason||o.controller.signal.aborted){a=Y(o.stopReason,"cancelled")}else{a="failed";l=ae(m)}}finally{d?.clear();if(this.activeRun===o)this.activeRun=void 0}const{usage:L}=j(y);let S={sessionId:c?.sessionId??"",turnId:t.turnId,status:a,answer:f,...t.model?{model:{...t.model}}:{},...L?{usage:L}:{},...y.length?{usageResponses:y}:{},..._?{usageIncomplete:true}:{},...l?{error:l}:{},durationMs:Math.max(0,this.nowMs()-u)};if(r){try{await r(S)}catch{a="failed";const m={category:"internal",code:"AUTOMATION_RESULT_WRITE_FAILED",message:"Could not publish the TUI automation result.",retryable:true};l=m;S={...S,status:a,error:m}}}o.resolveSettled();return{turnId:t.turnId,...c?{session:c}:{},status:a,outcome:S,...l?.message?{error:l.message}:{},...M?{observations:R}:{}}}async abort(){const t=this.activeRun;if(!t)return false;t.abortPromise??=this.stopAndSettle(t);return t.abortPromise}reportAnswerSelection(t){try{this.options.onAnswerSelection?.(t)}catch{}}async stopAndSettle(t){const i=await this.stopActive(t,"user_stop");const n=t.settled.then(()=>i);const r=await fe(n,this.options.cancellationSettlementTimeoutMs??ne);if(this.activeRun===t)this.activeRun=void 0;if(r.settled)return r.value;const o={turnId:t.turnId,settlement:n};o.settlement=n.finally(()=>{if(this.retiringRun===o)this.retiringRun=void 0});this.retiringRun=o;return i}async stopActive(t,i){t.stopReason??=i;const n=t.sessionId;const r=n?this.runtime.abortSession({id:n,turnId:t.turnId,reason:i==="limit"?"max_steps":i}).catch(()=>false):Promise.resolve(true);t.controller.abort(new Error(`Turn stopped: ${i}`));return r}};function ie(e,t,i){return{id:t.sessionId,turnId:e.turnId,content:e.content,...e.displayContent!==void 0?{displayContent:e.displayContent}:{},...i!==void 0?{executionDeadlineAtMs:i}:{},...e.executionDiagnostics?{executionDiagnostics:true}:{},...e.clientIntent?{clientIntent:e.clientIntent}:{},...e.reviewRequest?{reviewRequest:e.reviewRequest}:{},...e.attachments?.length?{attachments:e.attachments.map(n=>({meta:{attachmentType:n.type,fileName:n.fileName,mimeType:n.mimeType,sizeBytes:n.sizeBytes},local:{...n.filePath?{filePath:n.filePath}:{},...n.assetId?{assetId:n.assetId}:{}}}))}:{},...e.model?{model:{...e.model}}:{},...e.outputSchema?{outputSchema:e.outputSchema}:{}}}function q(e){return e.type==="message"&&e.message.role==="assistant"}function re(e){return e.type==="delta"&&e.role==="assistant"&&typeof e.content==="string"}function oe(e){return e.type==="generic"&&(e.eventType==="questionnaire.ask"||e.eventType==="runtime.action-required"&&e.data.kind==="questionnaire")}function se(e){if(!oe(e))return void 0;return $()}function $(){return{category:"runtime",code:"QUESTIONNAIRE_REQUIRED",message:"Questionnaire requires user input.",retryable:true}}function ue(e){if(e.type==="generic"&&e.eventType==="messages-rewound"){return{status:"failed",error:{category:"runtime",code:"CONTENT_REVIEW_BLOCKED",message:"Content review blocked the request.",retryable:true}}}if(e.type==="error"){return{status:"failed",error:{category:"runtime",message:e.message,retryable:true}}}if(e.type!=="session-status")return void 0;if(e.status==="error"){return{status:"failed",error:{category:"runtime",message:e.message??"Runtime turn failed.",retryable:true}}}if(e.status==="aborted"||e.status==="interrupted"){return{status:"cancelled"}}return void 0}function ae(e){if(e instanceof p){const t=e.category==="config"||e.category==="internal"?e.category:"runtime";return{category:t,code:e.code,message:e.message,retryable:e.retryable}}if(e&&typeof e==="object"){const t=e;if(typeof t.message==="string"){return{category:t.category==="config"||t.category==="internal"?t.category:"runtime",...typeof t.code==="string"?{code:t.code}:{},message:t.message,...typeof t.retryable==="boolean"?{retryable:t.retryable}:{retryable:true}}}}return{category:"runtime",message:e instanceof Error?e.message:String(e),retryable:true}}function Y(e,t){if(e==="timeout")return"timeout";if(e==="limit")return"limit_exceeded";if(e==="user_stop")return"cancelled";return t}async function z(e,t){try{await e(t)}catch{}}function ce(e,t){if(t.aborted)return Promise.resolve();return new Promise(i=>{const n=()=>{t.removeEventListener("abort",n);i()};t.addEventListener("abort",n,{once:true});void e.then(n,n)})}function de(e){let t=()=>void 0;const i=new Promise(n=>{t=n});return{turnId:e,controller:new AbortController,settled:i,resolveSettled:t}}async function le(e,t){if(t.aborted)return void 0;return new Promise((i,n)=>{const r=()=>t.removeEventListener("abort",o);const o=()=>{r();i(void 0)};t.addEventListener("abort",o,{once:true});e.then(u=>{r();i(u)},u=>{r();n(u)})})}function me(e,t){let i=t;let n;let r=false;const o=()=>{if(r)return;if(i<=0){e();return}const u=Math.min(i,te);i-=u;n=setTimeout(o,u);n.unref?.()};o();return{clear(){r=true;if(n)clearTimeout(n)}}}async function fe(e,t){if(t<=0)return{settled:false};let i;const n=await Promise.race([e.then(r=>({settled:true,value:r})),new Promise(r=>{i=setTimeout(()=>r({settled:false}),t);i.unref?.()})]);if(i)clearTimeout(i);return n}var V="Sign in to Alran to use Agent features. Run /login, then retry.";var I="Sign in to Alran to use Agent features. Run `alran login`, then retry.";var v=class extends p{constructor(i,n=I){super("config",n,{code:"auth.login_required",retryable:false});this.account=i;this.name="TuiLoginRequiredError"}account};function X(e){return e.managedTokenPresent===true||e.platformSessionPresent===true}function ge(e){if(e.modelSource)return e.modelSource==="token-plan";return e.authMode==="managed-login"}function H(e){return e.status==="needs-login"||ge(e)&&!X(e)}function xe(e){return H(e)}async function J(e,t,i,n){const r=await e.getAccountStatus(t,{...n,includeMembership:false});i?.(r);return r}async function pe(e,t,i=I,n,r){const o=await J(e,t,n,r);if(H(o)){throw new v(o,i)}return o}async function Te(e,t,i=I,n){const r=await J(e,t,n,{requireManagedAuth:true});if(!X(r)){throw new v(r,i)}return r}async function Me(e,t,i){const n=e.getAccountStatus;if(!n)return;await pe({getAccountStatus:n.bind(e)},t,V,i)}async function Ce(e,t,i){const n=e.getAccountStatus;if(!n)return;await Te({getAccountStatus:n.bind(e)},t,V,i)}import{stripVTControlCharacters as ye}from"node:util";function Oe(e,t=240){return Array.from(Re(e).replace(/[\u00ad\u061c\u200b\u200e\u200f\u202a-\u202e\u2066-\u2069\ufeff]/gu,"").replace(/\s+/gu," ").trim()).slice(0,t).join("")}function Re(e){const t=e.replace(/(?:\u001b\]|\u009d)[\s\S]*?(?:\u0007|\u001b\\|\u009c|$)|(?:\u001b[P^_X]|[\u0090\u0098\u009e\u009f])[\s\S]*?(?:\u001b\\|\u009c|$)/gu,"");return ye(t).replace(/\r\n/gu,"\n").replace(/\r/gu," ").replace(/[\u0000-\u0008\u000b\u000c\u000e-\u001f\u007f-\u009f]/gu,"")}export{Oe as a,Re as b,E as c,Q as d,F as e,j as f,K as g,ne as h,W as i,v as j,xe as k,pe as l,Me as m,Ce as n};
|